Skip to content

Conversation

@mashraf-222
Copy link
Contributor

Fix: Handle missing test file registration gracefully with improved path matching

  1. Path normalization: Added a helper that normalizes paths before comparison:

    • Resolves to absolute paths
    • Handles Windows case-insensitivity (only on Windows)
    • Works when files don't exist yet
  2. Error handling: Replaced the assertion with a warning that:

    • Logs the missing test file path
    • Lists registered test files for debugging
    • Skips the test case instead of crashing

Changes

  • models.py: Added _normalize_path_for_comparison() and updated path comparison methods to use it
  • parse_test_output.py: Replaced assertion with warning and continue

Impact

  • Prevents crashes when test files aren't registered
  • Improves debugging with clearer error messages
  • Handles Windows path differences correctly
  • Minimal code changes, no breaking changes

Fixes the crash and improves robustness when test file paths don't match exactly.

…oss-platform compatibility. Remove redundant path matching logic and enhance logging in parse_test_xml for better debugging of test type registration issues.
test_file
for test_file in self.test_files
if test_file.original_file_path is not None
and normalized == self._normalize_path_for_comparison(test_file.original_file_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

can refactor self._normalize_path_for_comparison(test_file.original_file_path) out for better readability

if normalized == self._normalize_path_for_comparison(test_file.instrumented_behavior_file_path)
or (
test_file.benchmarking_file_path is not None
and normalized == self._normalize_path_for_comparison(test_file.benchmarking_file_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

same feedback as previous comment

@codeflash-ai
Copy link
Contributor

codeflash-ai bot commented Jan 17, 2026

⚡️ Codeflash found optimizations for this PR

📄 702% (7.02x) speedup for TestFiles.get_by_original_file_path in codeflash/models/models.py

⏱️ Runtime : 4.19 milliseconds 522 microseconds (best of 15 runs)

A dependent PR with the suggested changes has been created. Please review:

If you approve, it will be merged into this PR (branch fix-path-resolution/no-gen-tests).

Static Badge

@codeflash-ai
Copy link
Contributor

codeflash-ai bot commented Jan 17, 2026

⚡️ Codeflash found optimizations for this PR

📄 73% (0.73x) speedup for TestFiles.get_test_type_by_original_file_path in codeflash/models/models.py

⏱️ Runtime : 597 microseconds 346 microseconds (best of 31 runs)

A dependent PR with the suggested changes has been created. Please review:

If you approve, it will be merged into this PR (branch fix-path-resolution/no-gen-tests).

Static Badge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants