Skip to content

Commit a3764f1

Browse files
Merge branch 'main' of github.com:codeflash-ai/codeflash into fix/js-jest30-loop-runner
2 parents 4c61d08 + 953b0fb commit a3764f1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

codeflash/discovery/functions_to_optimize.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,11 +839,13 @@ def is_test_file(file_path_normalized: str) -> bool:
839839
if any(pattern in file_lower for pattern in test_file_name_patterns):
840840
return True
841841
# Check directory patterns, but only within the project root
842-
# to avoid false positives from parent directories
843-
relative_path = file_lower
842+
# to avoid false positives from parent directories (e.g., project at /home/user/tests/myproject)
844843
if project_root_str and file_lower.startswith(project_root_str.lower()):
845844
relative_path = file_lower[len(project_root_str) :]
846-
return any(pattern in relative_path for pattern in test_dir_patterns)
845+
return any(pattern in relative_path for pattern in test_dir_patterns)
846+
# If we can't compute relative path from project root, don't check directory patterns
847+
# This avoids false positives when project is inside a folder named "tests"
848+
return False
847849
# Use directory-based filtering when tests are in a separate directory
848850
return file_path_normalized.startswith(tests_root_str + os.sep)
849851

0 commit comments

Comments
 (0)