Skip to content

fix(c-parser): anchor is_test_file patterns to path segments / filename boundaries#93

Open
gadievron wants to merge 1 commit into
masterfrom
fix/c-parser-anchor-is-test-file-patterns-to
Open

fix(c-parser): anchor is_test_file patterns to path segments / filename boundaries#93
gadievron wants to merge 1 commit into
masterfrom
fix/c-parser-anchor-is-test-file-patterns-to

Conversation

@gadievron

Copy link
Copy Markdown
Collaborator

RepositoryScanner.is_test_file matched test_patterns as bare substrings
(pattern in path_lower), so ordinary source files whose name/path merely
CONTAINED a pattern were wrongly skipped as tests when skip_tests=True:

  • latest_value.c (contains 'test_') -> skipped
  • contest/foo.c (contains 'test/') -> skipped

Match directory patterns (test/, tests/, fuzz/) against whole path segments,
and filename patterns against the basename: 'test' as a stem suffix and
'test
' as a prefix. The _test suffix is matched on the stem (before the
extension) so _test.cc / _test.cxx — which the old substring check also caught
— stay detected, bounded by is_source_file.

Adds tests/parsers/c/test_repository_scanner_is_test_file.py (RED->GREEN; both
true-positive and false-positive directions, incl. the _test.cc regression case).
GREEN: 2 passed (venv py3.11); ruff clean.

The same substring bug exists in the python/php/ruby repository_scanner.py —
handled in their own PRs (systemic family).

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

…me boundaries

RepositoryScanner.is_test_file matched test_patterns as bare substrings
(`pattern in path_lower`), so ordinary source files whose name/path merely
CONTAINED a pattern were wrongly skipped as tests when skip_tests=True:
  - latest_value.c  (contains 'test_')  -> skipped
  - contest/foo.c   (contains 'test/')  -> skipped

Match directory patterns (test/, tests/, fuzz/) against whole path *segments*,
and filename patterns against the basename: '_test' as a stem suffix and
'test_' as a prefix. The _test suffix is matched on the stem (before the
extension) so _test.cc / _test.cxx — which the old substring check also caught
— stay detected, bounded by is_source_file.

Adds tests/parsers/c/test_repository_scanner_is_test_file.py (RED->GREEN; both
true-positive and false-positive directions, incl. the _test.cc regression case).
GREEN: 2 passed (venv py3.11); ruff clean.

The same substring bug exists in the python/php/ruby repository_scanner.py —
handled in their own PRs (systemic family).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant