From 2f898d7bfefadc5fab4ec87395bd84d8be26df79 Mon Sep 17 00:00:00 2001 From: Brian <9775sgbccn@privaterelay.appleid.com> Date: Sat, 31 Oct 2026 13:19:25 -0400 Subject: [PATCH] test: keep non-symlink assertions running when symlinks are refused Review on #3830 found two places where the early return added in 09de2c24 also skipped assertions that never needed a symlink: - coordination-inventory: the oversized-JSON and missing-directory checks were skipped. The expected task count holds whether or not the link exists, so trySymlink is now called as a plain statement. - frontend-design-direction: the incomplete-gate, malformed-input and no-argument checks were skipped. Link-based artifacts are now appended only when their link succeeds, so a refusal narrows the case list instead of ending the test. The junction case now runs on Windows, where it previously sat behind two returns that had already fired. Also converts the one remaining direct fs.symlinkSync in opencode-consent-legacy-lock. Junctions are permitted without elevation on Windows, so that call did not fail here, but it still throws on a filesystem with no symlink support at all. --- tests/lib/opencode-consent-legacy-lock.test.js | 3 ++- tests/scripts/coordination-inventory.test.js | 3 ++- tests/skills/frontend-design-direction.test.js | 13 ++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/lib/opencode-consent-legacy-lock.test.js b/tests/lib/opencode-consent-legacy-lock.test.js index 4e65cc9e4..60b382af7 100644 --- a/tests/lib/opencode-consent-legacy-lock.test.js +++ b/tests/lib/opencode-consent-legacy-lock.test.js @@ -238,7 +238,8 @@ function runTests() { if (unrelated === 'file') fs.writeFileSync(value.legacyRoot, 'user file'); else if (unrelated === 'symlink') { fs.mkdirSync(value.canonicalRoot, { recursive: true }); - fs.symlinkSync(value.canonicalRoot, value.legacyRoot, process.platform === 'win32' ? 'junction' : 'dir'); + if (!trySymlink(value.canonicalRoot, value.legacyRoot, + process.platform === 'win32' ? 'junction' : 'dir')) return; } else { fs.mkdirSync(value.legacyRoot, { recursive: true }); if (unrelated === 'malformed-state') fs.writeFileSync(value.legacyStatePath, '{malformed'); diff --git a/tests/scripts/coordination-inventory.test.js b/tests/scripts/coordination-inventory.test.js index 5dfd152ce..87239b96a 100644 --- a/tests/scripts/coordination-inventory.test.js +++ b/tests/scripts/coordination-inventory.test.js @@ -88,7 +88,8 @@ test('task file adapter reads structured status, labels mtime, skips symlinks an const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'coordination-test-')); try { fs.mkdirSync(path.join(dir, 'worker')); fs.writeFileSync(path.join(dir, 'worker', 'STATUS.md'), '- State: running\n- Updated: 2026-09-08T06:29:00Z\n'); - if (!trySymlink(path.join(dir, 'worker'), path.join(dir, 'linked'))) return; + // The task count holds with or without the link, so a refusal must not skip the rest. + trySymlink(path.join(dir, 'worker'), path.join(dir, 'linked')); const r = collectTaskFiles(dir); assert.equal(r.tasks.length, 1); assert.equal(r.tasks[0].status, 'running'); assert.ok(r.tasks[0].statusFileModifiedAt); assert.equal(r.tasks[0].heartbeatAt, '2026-09-08T06:29:00Z'); fs.writeFileSync(path.join(dir, 'large.json'), ' '.repeat(1024 * 1024 + 1)); diff --git a/tests/skills/frontend-design-direction.test.js b/tests/skills/frontend-design-direction.test.js index aa95a8094..e46ef3dec 100644 --- a/tests/skills/frontend-design-direction.test.js +++ b/tests/skills/frontend-design-direction.test.js @@ -119,11 +119,14 @@ test('CLI requires a nonempty local artifact and fails safely on invalid input', assert.equal(run(input).status, 1, 'empty artifact must fail'); fs.writeFileSync(path.join(dir, 'render.png'), 'nonempty local artifact'); fs.writeFileSync(path.join(external, 'render.png'), 'nonempty external artifact'); - if (!trySymlink(path.join(dir, 'render.png'), path.join(dir, 'linked.png'))) return; - if (!trySymlink(path.join(external, 'render.png'), path.join(dir, 'outside'))) return; - fs.symlinkSync(external, path.join(dir, 'external-dir'), 'junction'); - for (const artifact of ['.', 'https://example.com/render.png', path.join(dir, 'render.png'), - '../render.png', 'C:\\render.png', 'linked.png', 'outside', 'external-dir/render.png']) { + // Add the link-based cases only where the OS allows the link, so a refusal + // narrows this list instead of skipping the gate and input checks below. + const artifacts = ['.', 'https://example.com/render.png', path.join(dir, 'render.png'), + '../render.png', 'C:\\render.png']; + if (trySymlink(path.join(dir, 'render.png'), path.join(dir, 'linked.png'))) artifacts.push('linked.png'); + if (trySymlink(path.join(external, 'render.png'), path.join(dir, 'outside'))) artifacts.push('outside'); + if (trySymlink(external, path.join(dir, 'external-dir'), 'junction')) artifacts.push('external-dir/render.png'); + for (const artifact of artifacts) { fs.writeFileSync(input, JSON.stringify({ ...report(), renderedEvidence: [{ viewport: '390x844', artifact, observation: 'Checked.' }] })); assert.equal(run(input).status, 1, 'directories and remote artifacts must fail'); }