Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,10 @@ def process_review(
generated_tests_str = ""
code_lang = self.function_to_optimize.language
for test in generated_tests.generated_tests:
if map_gen_test_file_to_no_of_tests[test.behavior_file_path] > 0:
if any(
test_file.name == test.behavior_file_path.name and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):
Comment on lines +2080 to +2083
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (low priority): Comparing only .name (filename without directory) works because generated test filenames include the function name, test type, and iteration index — making collisions unlikely in practice. However, comparing resolved paths would be more robust:

Suggested change
if any(
test_file.name == test.behavior_file_path.name and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):
if any(
test_file.resolve() == test.behavior_file_path.resolve() and count > 0
for test_file, count in map_gen_test_file_to_no_of_tests.items()
):

This would handle symlinks, relative vs absolute paths, and other normalization differences while avoiding any theoretical false-positive matches from same-named files in different directories.

formatted_generated_test = format_generated_code(
test.generated_original_test_source, self.args.formatter_cmds
)
Expand Down
Loading