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.
This commit is contained in:
Brian committed 2026-10-31 13:19:25 -04:00
1 parent 50cd840d72
commit 2f898d7bfe
3 files changed
+12 -7

No files matched your search

@@ -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');
+2 -1
View File
@@ -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));
@@ -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');
}