|
20 | 20 | from codeflash.optimization.function_optimizer import FunctionOptimizer |
21 | 21 | from codeflash.telemetry.posthog_cf import ph |
22 | 22 | from codeflash.verification.verification_utils import TestConfig |
| 23 | +from codeflash.code_utils.code_utils import cleanup_paths |
23 | 24 |
|
24 | 25 | if TYPE_CHECKING: |
25 | 26 | from argparse import Namespace |
@@ -177,16 +178,22 @@ def run(self) -> None: |
177 | 178 | logger.info("✨ All functions have been optimized! ✨") |
178 | 179 | finally: |
179 | 180 | if function_optimizer: |
180 | | - for test_file in function_optimizer.test_files.get_by_type(TestType.GENERATED_REGRESSION).test_files: |
181 | | - test_file.instrumented_behavior_file_path.unlink(missing_ok=True) |
182 | | - test_file.benchmarking_file_path.unlink(missing_ok=True) |
183 | | - for test_file in function_optimizer.test_files.get_by_type(TestType.EXISTING_UNIT_TEST).test_files: |
184 | | - test_file.instrumented_behavior_file_path.unlink(missing_ok=True) |
185 | | - test_file.benchmarking_file_path.unlink(missing_ok=True) |
186 | | - for test_file in function_optimizer.test_files.get_by_type(TestType.CONCOLIC_COVERAGE_TEST).test_files: |
187 | | - test_file.instrumented_behavior_file_path.unlink(missing_ok=True) |
188 | | - if function_optimizer.test_cfg.concolic_test_root_dir: |
189 | | - shutil.rmtree(function_optimizer.test_cfg.concolic_test_root_dir, ignore_errors=True) |
| 181 | + list_of_paths_to_delete = [ |
| 182 | + test_file.instrumented_behavior_file_path |
| 183 | + for test_type in [ |
| 184 | + TestType.GENERATED_REGRESSION, |
| 185 | + TestType.EXISTING_UNIT_TEST, |
| 186 | + TestType.CONCOLIC_COVERAGE_TEST, |
| 187 | + ] |
| 188 | + for test_file in function_optimizer.test_files.get_by_type(test_type).test_files |
| 189 | + ] + [ |
| 190 | + test_file.benchmarking_file_path |
| 191 | + for test_type in [TestType.GENERATED_REGRESSION, TestType.EXISTING_UNIT_TEST] |
| 192 | + for test_file in function_optimizer.test_files.get_by_type(test_type).test_files |
| 193 | + ] + [function_optimizer.test_cfg.concolic_test_root_dir] |
| 194 | + |
| 195 | + cleanup_paths(list_of_paths_to_delete) |
| 196 | + |
190 | 197 | if hasattr(get_run_tmp_file, "tmpdir"): |
191 | 198 | get_run_tmp_file.tmpdir.cleanup() |
192 | 199 |
|
|
0 commit comments