File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,6 @@ def run(self) -> None:
248248 return
249249 if not env_utils .check_formatter_installed (self .args .formatter_cmds ):
250250 return
251-
252251 if self .args .no_draft and is_pr_draft ():
253252 logger .warning ("PR is in draft mode, skipping optimization" )
254253 return
@@ -326,12 +325,32 @@ def run(self) -> None:
326325
327326 self .cleanup_temporary_paths ()
328327
328+ @staticmethod
329+ def find_leftover_instrumented_test_files (test_root : Path ) -> list [Path ]:
330+ """Search for all paths within the test_root that match the following patterns.
331+
332+ - 'test.*__perf_test_{0,1}.py'
333+ - 'test_.*__unit_{0,1}.py'
334+ - 'test_.*__perfinstrumented.py'
335+ - 'test_.*__perfonlyinstrumented.py'
336+ Returns a list of matching file paths.
337+ """
338+ import re
339+
340+ pattern = re .compile (
341+ r"^(test.*__perf_test_?\.py|test_.*__unit_?\.py|test_.*__perfinstrumented\.py|test_.*__perfonlyinstrumented\.py)$"
342+ )
343+
344+ return [file for file in test_root .rglob ("test_*.py" ) if pattern .match (file .name )]
345+
329346 def cleanup_temporary_paths (self ) -> None :
330347 from codeflash .code_utils .code_utils import cleanup_paths
331348
332349 if self .current_function_optimizer :
333350 self .current_function_optimizer .cleanup_generated_files ()
334351
352+ cleanup_paths (Optimizer .find_leftover_instrumented_test_files (self .test_cfg .tests_root ))
353+
335354 cleanup_paths ([self .test_cfg .concolic_test_root_dir , self .replay_tests_dir ])
336355
337356
You can’t perform that action at this time.
0 commit comments