fix: improve long-task wrapper cli errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { execFileSync, spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -102,8 +102,25 @@ function runFixture(fixture) {
|
||||
};
|
||||
}
|
||||
|
||||
function assertErrorCase(name, args, expectedStderr, input) {
|
||||
const result = spawnSync(process.execPath, [wrapperPath, ...args], {
|
||||
cwd: repoRoot,
|
||||
encoding: 'utf8',
|
||||
input,
|
||||
});
|
||||
|
||||
assert.notEqual(result.status, 0, `${name}: expected non-zero exit`);
|
||||
assert.equal(result.stdout, '', `${name}: expected empty stdout`);
|
||||
assert.equal(result.stderr.trim(), expectedStderr, `${name}: unexpected stderr`);
|
||||
}
|
||||
|
||||
function main() {
|
||||
const results = fixtures.map(runFixture);
|
||||
|
||||
assertErrorCase('invalid json', ['--compact'], 'INVALID_JSON: input must be valid JSON', 'not-json\n');
|
||||
assertErrorCase('missing input value', ['--input'], 'CLI_ERROR: --input requires a value');
|
||||
assertErrorCase('unknown argument', ['--bogus'], 'CLI_ERROR: unknown argument: --bogus');
|
||||
|
||||
const summary = {
|
||||
passed: results.length,
|
||||
fixtures: results.map(({ name, output }) => ({
|
||||
@@ -114,6 +131,7 @@ function main() {
|
||||
requiredNextAction: output.requiredNextAction,
|
||||
handoffMode: output.handoff.mode,
|
||||
})),
|
||||
errorCases: 3,
|
||||
};
|
||||
|
||||
process.stdout.write(JSON.stringify(summary, null, 2) + '\n');
|
||||
|
||||
Reference in New Issue
Block a user