diff --git a/lib/pregate/checks/literals.ts b/lib/pregate/checks/literals.ts index 314e28b93..034de66db 100644 --- a/lib/pregate/checks/literals.ts +++ b/lib/pregate/checks/literals.ts @@ -61,8 +61,8 @@ function unquote(v: string): string { return /^['"`]/.test(v) ? v.slice(1, -1) : /** * Test files that still carry the old literal beside the constant's name or - * its module. The module counts only as a path fragment (`/install.sh`, - * `/retry.js`, `/retry'`): a bare stem such as `install` or `retry` is an + * its module. The module counts as its full file name (`install.sh`) or as a + * path fragment (`/retry.js`, `/retry'`): a bare stem such as `install` or `retry` is an * English word in half the test tree, and a one-character old value (`2`) * sits in every test, so that value needs the constant's name (a wrapper * version 2 → 3 flagged 575 consumers through the stem alone). @@ -72,7 +72,7 @@ export function consumersOf(repoRoot: string, testFiles: readonly string[], chan const valueRe = /^-?\d/.test(value) ? new RegExp(`(? { 'test/other.test.ts': ['expect(install.steps.length).toBe(2);', ''].join(nl), 'test/retry.test.ts': ["expect(require('../lib/retry.js').TIMEOUT_MS).toBe(5000);", ''].join(nl), 'test/retry-path.test.ts': ["const mod = require('../lib/retry.js');", 'expect(mod.wait()).toBe(5000);', ''].join(nl), + 'test/retry-bare.test.ts': ["const mod = load('retry.js');", 'expect(mod.wait()).toBe(5000);', ''].join(nl), + 'test/reretry.test.ts': ["const mod = load('preretry.js');", 'expect(mod.wait()).toBe(5000);', ''].join(nl), 'test/retry-words.test.ts': ['// the retry budget was 5000 once', 'expect(elapsed).toBeLessThan(5000);', ''].join(nl), }; for (const [rel, text] of Object.entries(files)) { fs.mkdirSync(path.dirname(path.join(root, rel)), { recursive: true }); fs.writeFileSync(path.join(root, rel), text); } const all = Object.keys(files); // A one-character value: only the file that names the constant counts; the path fragment alone is not enough for "2". expect(consumersOf(root, all, { name: 'GSTACK_CAPY_WRAPPER', old: '2', new: '3', file: 'capy/skill/gstack/scripts/install.sh' })).toEqual(['test/wrapper.test.ts:2']); - // A longer value: the constant's name or the module as a path fragment; the bare word "retry" in prose does not count. - expect(consumersOf(root, all, { name: 'TIMEOUT_MS', old: '5000', new: '9000', file: 'lib/retry.js' })).toEqual(['test/retry.test.ts:1', 'test/retry-path.test.ts:2']); + // A longer value: the constant's name, the module's full file name, or its stem as a path fragment; the bare word "retry" in prose and "preretry.js" do not count. + expect(consumersOf(root, all, { name: 'TIMEOUT_MS', old: '5000', new: '9000', file: 'lib/retry.js' })).toEqual(['test/retry.test.ts:1', 'test/retry-path.test.ts:2', 'test/retry-bare.test.ts:2']); fs.rmSync(root, { recursive: true, force: true }); }); test('runner summaries: bun, node --test, vitest, jest, pytest, zero-run', () => {