Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/signals/test-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export function isTestPath(file: string): boolean {
/(^|\/)(test|tests|spec|__tests__)\//i.test(file) ||
/(^|\/)src\/test\//i.test(file) ||
/(^|\/)[^/]+_test\.(go|py|rb)$/i.test(file) ||
/(^|\/)test_[^/]*\.py$/i.test(file) || // pytest's default `test_*.py` prefix convention (the suffix rule above only catches `*_test.py`)
/(^|\/)[^/]+_spec\.rb$/i.test(file) ||
/\.(test|spec)\.(ts|tsx|js|jsx|py|rb|rs)$/i.test(file) ||
/(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|js|jsx)$/i.test(file) ||
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test-evidence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ describe("test evidence helpers", () => {
expect(isTestPath("src/widget.rs")).toBe(false);
});

it("detects pytest's default test_*.py prefix convention, not just the *_test.py suffix", () => {
expect(isTestPath("mypackage/test_utils.py")).toBe(true); // pytest default, sitting next to source
expect(isTestPath("src/app/test_auth.py")).toBe(true);
expect(isTestPath("test_top_level.py")).toBe(true); // repo-root test file
expect(isTestPath("internal/cache_test.py")).toBe(true); // the pre-existing suffix form still matches
expect(isTestPath("src/app/latest_config.py")).toBe(false); // `test_` mid-segment ⇒ not a test
expect(isTestPath("src/app/testing.py")).toBe(false); // no `test_` boundary ⇒ not a test
});

it("does not treat framework or integration directory names alone as test evidence", () => {
expect(isTestPath("src/integration/auth.ts")).toBe(false);
expect(isTestPath("src/playwright/client.ts")).toBe(false);
Expand Down
Loading