Update test_runner.py
Browse files- test_runner.py +13 -13
test_runner.py
CHANGED
|
@@ -72,19 +72,19 @@ class TestRunner:
|
|
| 72 |
"""Extract the target function name from the code.
|
| 73 |
Looks for a function named 'fix' first; otherwise returns the first function found.
|
| 74 |
"""
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
def _generate_test_script(self, fix_code: str, func_name: str) -> str:
|
| 90 |
"""Generate a test script that runs fixed + fuzzed test cases and outputs JSON."""
|
|
|
|
| 72 |
"""Extract the target function name from the code.
|
| 73 |
Looks for a function named 'fix' first; otherwise returns the first function found.
|
| 74 |
"""
|
| 75 |
+
try:
|
| 76 |
+
tree = ast.parse(code)
|
| 77 |
+
first_func = None
|
| 78 |
+
for node in ast.walk(tree):
|
| 79 |
+
if isinstance(node, ast.FunctionDef):
|
| 80 |
+
if node.name == "fix":
|
| 81 |
+
return "fix"
|
| 82 |
+
if first_func is None:
|
| 83 |
+
first_func = node.name
|
| 84 |
+
return first_func # fallback if no 'fix' function exists
|
| 85 |
+
except SyntaxError:
|
| 86 |
+
pass
|
| 87 |
+
return None
|
| 88 |
|
| 89 |
def _generate_test_script(self, fix_code: str, func_name: str) -> str:
|
| 90 |
"""Generate a test script that runs fixed + fuzzed test cases and outputs JSON."""
|