Added a flag to track if at least one optimization was found, and added a cleanup step to remove test files if no optimizations were found.
This commit is contained in:
parent
ffc3877770
commit
6158c38c02
1 changed files with 8 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ def main() -> None:
|
|||
)
|
||||
test_files_created = set()
|
||||
existing_unit_tests = set()
|
||||
found_atleast_one_optimization = False
|
||||
try:
|
||||
functions_to_tests_map = discover_unit_tests(
|
||||
args.tests_root, args.root, test_framework=args.test_framework
|
||||
|
|
@ -248,8 +249,13 @@ def main() -> None:
|
|||
f.write(original_code)
|
||||
print("----------------")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
# TODO: Also revert the file/function being optimized if the process did not succeed
|
||||
|
||||
if not found_atleast_one_optimization:
|
||||
for test_file in test_files_created:
|
||||
if os.path.exists(test_file):
|
||||
os.remove(test_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Reference in a new issue