From ee77b3a9302c9a372d0fe3dc6b53fd1718cba797 Mon Sep 17 00:00:00 2001 From: haelyra <49814733+haelyra@users.noreply.github.com> Date: Sun, 11 Oct 2026 13:45:04 -0400 Subject: [PATCH] test: allow bounded CLI startup on loaded runners --- tests/lib/eval-harness/cli.test.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/lib/eval-harness/cli.test.js b/tests/lib/eval-harness/cli.test.js index e552da166..fbfd7bf4a 100644 --- a/tests/lib/eval-harness/cli.test.js +++ b/tests/lib/eval-harness/cli.test.js @@ -8,7 +8,9 @@ const vm = require('vm'); const { test, tempDir, cleanup, finish } = require('./helpers'); const harness = require('../../../scripts/lib/eval-harness'); const cli = path.resolve(__dirname, '../../../scripts/eval-harness.js'); -const run = args => spawnSync(process.execPath, [cli, ...args], { encoding: 'utf8', timeout: 3000 }); +// Allow bounded process startup under loaded native runners; still fail hangs. +const CLI_TIMEOUT_MS = 15000; +const run = args => spawnSync(process.execPath, [cli, ...args], { encoding: 'utf8', timeout: CLI_TIMEOUT_MS }); // Exercise spawn failures without starting an example, mutating the real // process object, or depending on a host-specific missing executable. @@ -76,13 +78,28 @@ test('dangling receipt value flags are usage errors before reading missing input for (const flag of ['--artifact', '--gate', '--out']) { for (const tail of [[flag], [flag, '--artifact']]) { const result = run([...command, ...tail]); - assert.strictEqual(result.status, 2, `${tail}: ${result.stderr}`); + assert.strictEqual(result.status, 2, `${tail}: ${result.error?.code || result.signal || result.stderr}`); assert.match(result.stderr, /needs a value/); } } } }); +test('usage validation survives a bounded slow child startup', () => { + const dir = tempDir('cli-slow-start'); + try { + const preload = path.join(dir, 'startup-delay.cjs'); + fs.writeFileSync(preload, 'Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3500);\n'); + const result = spawnSync(process.execPath, ['--require', preload, cli, + 'receipt', 'verify', '/absent-receipt', '/absent-capsule', '--out'], { + encoding: 'utf8', timeout: CLI_TIMEOUT_MS, + }); + assert.strictEqual(result.status, 2, result.error?.code || result.signal || result.stderr); + assert.strictEqual(result.stdout, ''); + assert.match(result.stderr, /needs a value/); + } finally { cleanup(dir); } +}); + test('invalid output flag does not cause producer projection writes', () => { const dir = tempDir('cli-build'); try {