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:
248
248
return
249
249
if not env_utils .check_formatter_installed (self .args .formatter_cmds ):
250
250
return
251
-
252
251
if self .args .no_draft and is_pr_draft ():
253
252
logger .warning ("PR is in draft mode, skipping optimization" )
254
253
return
@@ -326,12 +325,32 @@ def run(self) -> None:
326
325
327
326
self .cleanup_temporary_paths ()
328
327
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
+
329
346
def cleanup_temporary_paths (self ) -> None :
330
347
from codeflash .code_utils .code_utils import cleanup_paths
331
348
332
349
if self .current_function_optimizer :
333
350
self .current_function_optimizer .cleanup_generated_files ()
334
351
352
+ cleanup_paths (Optimizer .find_leftover_instrumented_test_files (self .test_cfg .tests_root ))
353
+
335
354
cleanup_paths ([self .test_cfg .concolic_test_root_dir , self .replay_tests_dir ])
336
355
337
356
You can’t perform that action at this time.
0 commit comments