@@ -185,10 +185,9 @@ def validate_stdout_in_candidate(stdout: str, expected_in_stdout: list[str]) ->
185
185
186
186
187
187
def run_trace_test (cwd : pathlib .Path , config : TestConfig , expected_improvement_pct : int ) -> bool :
188
- # First command: Run the tracer
189
188
test_root = cwd / "tests" / (config .test_framework or "" )
190
189
clear_directory (test_root )
191
- command = ["python" , "-m" , "codeflash.tracer " , "-o" , "codeflash.trace " , "workload.py" ]
190
+ command = ["python" , "-m" , "codeflash.main " , "optimize " , "workload.py" ]
192
191
process = subprocess .Popen (
193
192
command , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , text = True , cwd = str (cwd ), env = os .environ .copy ()
194
193
)
@@ -202,33 +201,20 @@ def run_trace_test(cwd: pathlib.Path, config: TestConfig, expected_improvement_p
202
201
stdout = "" .join (output )
203
202
204
203
if return_code != 0 :
205
- logging .error (f"Tracer command returned exit code { return_code } " )
204
+ logging .error (f"Tracer with optimization command returned exit code { return_code } " )
206
205
return False
207
206
208
- functions_traced = re .search (r"Traced (\d+) function calls successfully and replay test created at - (.*)$" , stdout )
209
- if not functions_traced or int (functions_traced .group (1 )) != 13 :
210
- logging .error ("Expected 13 traced functions" )
207
+ functions_traced = re .search (r"Traced (\d+) function calls successfully" , stdout )
208
+ logging .info (functions_traced .groups () if functions_traced else "No functions traced" )
209
+ if not functions_traced :
210
+ logging .error ("Failed to find traced functions in output" )
211
211
return False
212
-
213
- replay_test_path = pathlib .Path (functions_traced .group (2 ))
214
- if not replay_test_path .exists ():
215
- logging .error (f"Replay test file missing at { replay_test_path } " )
212
+ if int (functions_traced .group (1 )) != 13 :
213
+ logging .error (functions_traced .groups ())
214
+ logging .error ("Expected 13 traced functions" )
216
215
return False
217
216
218
- # Second command: Run optimization
219
- command = ["python" , "../../../codeflash/main.py" , "--replay-test" , str (replay_test_path ), "--no-pr" ]
220
- process = subprocess .Popen (
221
- command , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , text = True , cwd = str (cwd ), env = os .environ .copy ()
222
- )
223
-
224
- output = []
225
- for line in process .stdout :
226
- logging .info (line .strip ())
227
- output .append (line )
228
-
229
- return_code = process .wait ()
230
- stdout = "" .join (output )
231
-
217
+ # Validate optimization results (from optimization phase)
232
218
return validate_output (stdout , return_code , expected_improvement_pct , config )
233
219
234
220
0 commit comments