fix(c-parser): anchor is_test_file patterns to path segments / filename boundaries#93
Open
gadievron wants to merge 1 commit into
Open
fix(c-parser): anchor is_test_file patterns to path segments / filename boundaries#93gadievron wants to merge 1 commit into
gadievron wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RepositoryScanner.is_test_file matched test_patterns as bare substrings
(
pattern in path_lower), so ordinary source files whose name/path merelyCONTAINED a pattern were wrongly skipped as tests when skip_tests=True:
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