From d6bf36b3c625eccfaee51436422852268d461b44 Mon Sep 17 00:00:00 2001 From: Dev-3 Date: Tue, 17 Nov 2026 04:28:01 +0000 Subject: [PATCH] fix(testing-layers): stop the test-file walk at a nested checkout's boundary collectTestFiles walked every directory under the root, so a linked worktree or a clone parked under the checkout (a developer's tmp//) had its test copies read as this repository's files and the check failed with "unclassified test file" for copies no suite row should ever cover - on this box, ~60 parked worktrees turned the scripts+policy stage red (684/686) while CI's clean checkout stayed green. A directory that carries its own .git - a linked worktree's gitdir: file or a clone's store - is another repository's checkout: the walk now stops at that boundary the way it stops at node_modules. A genuinely new test file inside this repository still fails the check, so #749's acceptance is unchanged. --- .github/scripts/testing-layers.mjs | 7 +++++++ .github/scripts/testing-layers.test.mjs | 27 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/.github/scripts/testing-layers.mjs b/.github/scripts/testing-layers.mjs index 9fac64b4c..1b55d4d08 100644 --- a/.github/scripts/testing-layers.mjs +++ b/.github/scripts/testing-layers.mjs @@ -39,6 +39,12 @@ export function globMatch(pattern, path) { return new RegExp('^' + re + '$').test(path) } +// A directory below the root that carries its own `.git` — a linked worktree's `gitdir:` file, a +// clone's store — is another checkout parked under this one (a developer's `tmp//`), and +// none of its files is this repository's to classify: the walk stops at that boundary the way it +// stops at `node_modules`. The root's own `.git` is skipped by name and never checked here. +const isAnotherCheckout = (abs) => existsSync(join(abs, '.git')) + export function collectTestFiles(root) { const out = [] const walk = (dir) => { @@ -46,6 +52,7 @@ export function collectTestFiles(root) { const rel = dir ? `${dir}/${entry.name}` : entry.name if (entry.isDirectory()) { if (SKIP_DIRS.has(entry.name) || entry.name.startsWith('.dsh-test-')) continue + if (isAnotherCheckout(join(root, rel))) continue walk(rel) } else if (/\.test\.(m?[jt]s|cjs)$/.test(entry.name)) out.push(rel) } diff --git a/.github/scripts/testing-layers.test.mjs b/.github/scripts/testing-layers.test.mjs index c4f98cb56..75e1aa30f 100644 --- a/.github/scripts/testing-layers.test.mjs +++ b/.github/scripts/testing-layers.test.mjs @@ -85,6 +85,33 @@ test('#749: a new test file nobody classified fails the check, and so does a new } finally { rmSync(root, { recursive: true, force: true }) } }) +// A linked worktree a developer parks under the checkout (`tmp//`, carrying its own `.git` +// file) is another repository's checkout, not a file this repository holds: its test copies are not +// this check's to classify, while a genuinely new test file inside this repository still is. +test('#749: a nested checkout under the root is not this repository\'s to classify', () => { + const root = fixture({ + suites: [realSuite('core')], + workflows: [realWorkflow('test')], + files: ['core/test/a.test.js', 'misc/unregistered.test.js'], + workflowsOnDisk: ['.github/workflows/test.yml'], + }) + try { + // A linked worktree: its `.git` is a file pointing at the main checkout's store. + const linked = join(root, 'tmp', 'w-stranger') + mkdirSync(join(linked, 'core', 'test'), { recursive: true }) + writeFileSync(join(linked, '.git'), 'gitdir: /elsewhere/.git/worktrees/w-stranger\n') + writeFileSync(join(linked, 'core', 'test', 'copy.test.js'), '// another checkout\'s file\n') + // A full clone parked the same way: its `.git` is a directory. + const clone = join(root, 'tmp', 'clone-stranger') + mkdirSync(join(clone, 'core', 'test'), { recursive: true }) + mkdirSync(join(clone, '.git')) + writeFileSync(join(clone, 'core', 'test', 'copy.test.js'), '// another checkout\'s file\n') + const { problems } = check({ root }) + assert.equal(problems.length, 1, problems.join('\n')) + assert.ok(problems[0].includes('misc/unregistered.test.js'), problems.join('\n')) + } finally { rmSync(root, { recursive: true, force: true }) } +}) + test('#749: a "none" row without a reason, and a stale doc, are both reported', () => { const suites = [ realSuite('core'),