Skip to content

Commit 866f416

Browse files
committed
test(devx): assert the freshness predicate the walk applies, not a copy of it
The self-test's source-file cases re-spelled `SOURCE_FILE.test(name) && !TEST_FILE.test(name)` inline, so they pinned the two constants and nothing about how `newestSourceMtime` combines them -- an assertion that would stay green through a walk that had stopped excluding test files. Name the predicate and call it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KNfj35pXRxnF1D3gZN5zjc
1 parent e7c35e7 commit 866f416

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/check-type-check-coverage.mjs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,17 @@ function staleClosure(roots, graph) {
14131413
});
14141414
}
14151415

1416+
/**
1417+
* Whether a file name is one a package's `dist/*.d.ts` can be generated from.
1418+
* Named, rather than inlined into the walk below, so the self-test asserts the
1419+
* predicate the walk actually applies instead of a copy of it.
1420+
*
1421+
* @param {string} name basename
1422+
*/
1423+
function isBuildSource(name) {
1424+
return SOURCE_FILE.test(name) && !TEST_FILE.test(name);
1425+
}
1426+
14161427
/**
14171428
* The newest mtime among the TypeScript sources a package's `dist/*.d.ts` is
14181429
* generated from, or 0 when it has none.
@@ -1449,7 +1460,7 @@ function newestSourceMtime(dir) {
14491460
walk(child);
14501461
continue;
14511462
}
1452-
if (!SOURCE_FILE.test(entry.name) || TEST_FILE.test(entry.name)) continue;
1463+
if (!isBuildSource(entry.name)) continue;
14531464
const { mtimeMs } = statSync(child);
14541465
if (mtimeMs > newest) newest = mtimeMs;
14551466
}
@@ -2710,7 +2721,7 @@ function selfTest() {
27102721
{ label: 'a .json fixture is not', name: 'fixture.json', expect: false },
27112722
];
27122723
for (const c of sourceFileCases) {
2713-
const got = SOURCE_FILE.test(c.name) && !TEST_FILE.test(c.name);
2724+
const got = isBuildSource(c.name);
27142725
if (got !== c.expect) {
27152726
failures.push(`source-file read — ${c.label}: expected ${c.expect}, got ${got}`);
27162727
}

0 commit comments

Comments
 (0)