Commit graph

4 commits

Author SHA1 Message Date
Sarthak Agarwal
81be416043
Merge pull request #1991 from codeflash-ai/fix/verifier-path-validation
Fix: Handle test paths outside tests_root in verifier.py
2026-04-04 16:31:52 +05:30
claude[bot]
ba0d2bc9a3 style: add missing -> None return type annotations to test methods 2026-04-04 07:52:21 +00:00
mohammed ahmed
218f3b5014 Fix test path validation error for JS/TS tests outside tests_root
When JavaScript/TypeScript support generates test files in __tests__
subdirectories adjacent to source files (e.g., src/foo/__tests__/codeflash-generated/),
these test files are not within the configured tests_project_rootdir.

Previously, verifier.py:37 called module_name_from_file_path() without
handling the ValueError that occurs when the test path is outside tests_root,
causing optimization runs to crash.

This fix adds try-except handling with a fallback to using just the filename,
matching the pattern already used in javascript/parse.py:330-333.

Fixes trace ID: 84f5467f-8acf-427f-b468-02cb3342097e

Changes:
- codeflash/verification/verifier.py:37-48: Added try-except for path computation
- tests/verification/test_verifier_path_handling.py: Added unit tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 02:39:52 +00:00
mohammed ahmed
933a2602c3 Fix: Make coverage error messages framework-agnostic
Error messages in coverage_utils.py hardcoded "Jest" even when the
test framework was Vitest. This caused confusion in logs when Vitest
tests failed (e.g., "Jest coverage file not found" when using Vitest).

The JestCoverageUtils class is used for both Jest and Vitest since
they share the same Istanbul/v8 coverage format. Error messages
should be framework-agnostic.

Changes:
- "Jest coverage file not found" → "JavaScript coverage file not found"
- "Failed to parse Jest coverage file" → "Failed to parse JavaScript coverage file"
- "No coverage data found for X in Jest coverage" → "No coverage data found for X in JavaScript coverage"
- "Function X not found in Jest fnMap" → "Function X not found in JavaScript fnMap"

Affected trace IDs: 37e5a406, 735555fa, 940dfe80, c1e1de0e, dbec6c33, de96b1ab, fcf08c6b (7 logs from Apr 4 00:50 batch)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-04 00:55:03 +00:00