v1.91.348.0 pregate: map tests to dotfiles named in quoted literals (GST-246) (#3661)

* pregate: map tests to dotfiles named in quoted literals

The quoted-literal pattern required [A-Za-z0-9_@] after the relative prefix, so "../.gitleaks.toml" never matched, and a dot-led literal resolved beside the test instead of from the repo root. A branch touching only the dotfile ended in PREGATE_NO_LANE (GST-246, garrytan/truther#956).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* pregate: dotfile literals as their own pass; dot-led literals also resolve from the naming file's folder

Review fixes for #3661: the optional dot in QUOTED let a closing quote followed
by .method( consume the next literal's opening quote, dropping an edge main
found; and join(__dirname, '.github', ...) lost its fixture edge. Regression
test fails at acd2274.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-10-31 02:58:48 +00:00
1 parent 03488f5cef
commit 4eae3ef27d
6 files changed
+53 -5

No files matched your search

+40
View File
@@ -48,6 +48,46 @@ describe('import graph: route-group / dynamic-segment paths and tsconfig path al
expect(testsFor(buildGraph(repo.work), 'ship/sections/pr-body.md.tmpl').tests).toEqual(['test/publication.test.ts']);
});
test('a dotfile named by a quoted literal or a join() maps, relative or from the repo root', () => {
const repo = fixture();
commit(repo, {
'.gitleaks.toml': 'title = "x"\n',
'.github/workflows/ci.yml': 'on: push\n',
'test/relative.test.ts': "import { readFileSync } from 'node:fs';\nreadFileSync(new URL('../.gitleaks.toml', import.meta.url), 'utf8');\n",
'test/rooted.test.ts': "import { readFileSync } from 'node:fs';\nreadFileSync('.gitleaks.toml', 'utf8');\n",
'test/joined.test.ts': "import { join } from 'node:path';\nimport { readFileSync } from 'node:fs';\nreadFileSync(join('.github', 'workflows', 'ci.yml'), 'utf8');\n",
});
const g = buildGraph(repo.work);
expect(testsFor(g, '.gitleaks.toml').tests).toEqual(['test/relative.test.ts', 'test/rooted.test.ts']);
expect(testsFor(g, '.github/workflows/ci.yml').tests).toEqual(['test/joined.test.ts']);
});
test('a dot-led literal keeps the edges the base found: no swallowed quote, fixture dotfiles still map', () => {
const repo = fixture();
commit(repo, {
'test/fixtures/x.md': 'x\n',
'.github/workflows/ci.yml': 'on: push\n',
'test/.github/workflows/ci.yml': 'on: push\n',
'test/method.test.ts': "const d = 'a';\nexport const hit = `${d}`.includes('test/fixtures/x.md');\n",
'test/config.test.ts': "import { join } from 'node:path';\nimport { readFileSync } from 'node:fs';\nreadFileSync(join(__dirname, '.github', 'workflows', 'ci.yml'), 'utf8');\n",
});
const g = buildGraph(repo.work);
expect(testsFor(g, 'test/fixtures/x.md').tests).toEqual(['test/method.test.ts']);
expect(testsFor(g, 'test/.github/workflows/ci.yml').tests).toEqual(['test/config.test.ts']);
expect(testsFor(g, '.github/workflows/ci.yml').tests).toEqual(['test/config.test.ts']);
});
test('a dot-led literal that names no repo file adds no edge (extensions, missing dotfiles)', () => {
const repo = fixture();
commit(repo, {
'lib/plan.ts': 'export const plan = 1;\n',
'test/ext.test.ts': "const exts = ['.ts', '.md', '.env', '../.missing.toml', '.github'];\nexport { exts };\n",
});
const g = buildGraph(repo.work);
expect(testsFor(g, 'lib/plan.ts').tests).toEqual([]);
expect([...g.reverse.values()].flat().filter(e => e.from === 'test/ext.test.ts')).toEqual([]);
});
test('a relative import of a bracketed path already maps (control: the import scanner is not the bug)', () => {
const repo = fixture();
commit(repo, {