Commit

A file named test.js or spec.rb counts as a test: confidence no longer says tests not added when they were

syntaqxcommitted Parent1b205e2Browse files
3 files+12−20/3 viewed
+2−0
159159 assert.ok(isTestFile("pkg/store_test.go"));
160160 assert.ok(!isTestFile("src/testing-utils.ts"));
161161 assert.ok(!isTestFile("src/contest.ts"));
162+ assert.ok(isTestFile("test.js"));
163+ assert.ok(isTestFile("lib/spec.rb"));
162164 });
163165
164166 const merged = (daysAgo: number, mergedBy: string | null, number = 1, authoredByAgent = true): Merged => ({
+7−1
183183
184184 /** Test files, by the names test runners look for. */
185185 export function isTestFile(path: string): boolean {
186− return /(^|\/)(__tests__|tests?|spec)\//i.test(path) || /[._-](test|spec)\.[a-z0-9]+$/i.test(path) || /_test\.(go|rs|py)$/i.test(path);
186+ return (
187+ /(^|\/)(__tests__|tests?|spec)\//i.test(path) ||
188+ /[._-](test|spec)\.[a-z0-9]+$/i.test(path) ||
189+ /_test\.(go|rs|py)$/i.test(path) ||
190+ // A file named for what it is: test.js, tests.py, spec.rb.
191+ /(^|\/)(tests?|specs?)\.[a-z0-9]+$/i.test(path)
192+ );
187193 }
188194
189195 const plural = (n: number, one: string, many = `${one}s`) => `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
+3−1
123123 lower.split('/').any(|dir| matches!(dir, "test" | "tests" | "__tests__" | "spec" | "specs" | "testdata"))
124124 || [".test.", ".spec.", "_test.", "-test.", "_spec."].iter().any(|mark| file.contains(mark))
125125 || file.starts_with("test_")
126+ // A file named for what it is: test.js, tests.py, spec.rb.
127+ || matches!(file.split('.').next(), Some("test" | "tests" | "spec" | "specs")) && file.contains('.')
126128 }
127129
128130 /// Files that change nothing that runs: prose and pictures.
967969
968970 #[test]
969971 fn tests_prose_and_sensitive_paths_are_told_apart() {
970− for path in ["src/__tests__/a.ts", "tests/test_api.py", "pkg/api_test.go", "src/a.spec.tsx", "crates/x/tests/it.rs"] {
972+ for path in ["src/__tests__/a.ts", "tests/test_api.py", "pkg/api_test.go", "src/a.spec.tsx", "crates/x/tests/it.rs", "test.js", "lib/spec.rb"] {
971973 assert!(is_test(path), "{path}");
972974 }
973975 for path in ["src/testing.ts", "src/contest.rs", "attest/a.rs"] {