mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-30 04:15:22 +00:00
test: reproduce profile global dry-run ordering
RED: node tests/scripts/profile.test.js reports 27 passed and 4 failed. Leading --dry-run prevents subcommand recognition for show, preview, and explain; parser ordering regression exercises every argument position and preserves malformed-input rejection.
This commit is contained in:
1 file changed
+35
@@ -121,6 +121,24 @@ const tests = [
|
||||
['global dry-run remains compatible with profile inspection', () => withFixture(run => {
|
||||
success(run(['preview', '--target', 'codex', '--dry-run', '--json']));
|
||||
})],
|
||||
['global dry-run is ignored at every argument position without changing parsed controls', () => {
|
||||
const { parseArgs } = require('../../scripts/profile');
|
||||
for (const args of [
|
||||
['show', 'lean@1', '--json'],
|
||||
['preview', 'lean@1', '--target', 'codex', '--selection', 'auto',
|
||||
'--include', 'skill:security-review', '--exclude', 'skill:python-patterns', '--json'],
|
||||
['explain', 'skill:ecc-guide', '--target', 'codex', '--json'],
|
||||
]) {
|
||||
const expected = parseArgs(args);
|
||||
for (let index = 0; index <= args.length; index++) {
|
||||
const invocation = [...args.slice(0, index), '--dry-run', ...args.slice(index)];
|
||||
const before = [...invocation];
|
||||
assert.deepStrictEqual(parseArgs(invocation), expected, invocation.join(' '));
|
||||
assert.deepStrictEqual(invocation, before, 'parsing must preserve caller arguments');
|
||||
}
|
||||
assert.deepStrictEqual(parseArgs(['--dry-run', ...args, '--dry-run']), expected);
|
||||
}
|
||||
}],
|
||||
['package includes the direct profile entrypoint and public schemas', () => {
|
||||
const { files } = require('../../package.json');
|
||||
assert.ok(files.includes('scripts/profile.js'));
|
||||
@@ -129,8 +147,24 @@ const tests = [
|
||||
}],
|
||||
];
|
||||
|
||||
for (const args of [
|
||||
['show', 'lean@1', '--json'],
|
||||
['preview', 'lean@1', '--target', 'codex', '--selection', 'auto', '--json'],
|
||||
['explain', 'skill:ecc-guide', '--target', 'codex', '--json'],
|
||||
]) {
|
||||
tests.push([`leading global dry-run preserves ${args[0]} through both CLI entrypoints`, () => withFixture(run => {
|
||||
const expected = success(run(args));
|
||||
for (const direct of [false, true]) {
|
||||
const observed = success(run(['--dry-run', ...args], direct));
|
||||
assert.deepStrictEqual(observed, expected);
|
||||
assert.strictEqual(observed.activation, 'unobserved');
|
||||
}
|
||||
})]);
|
||||
}
|
||||
|
||||
for (const args of [
|
||||
['use', 'lean@1'],
|
||||
['--dry-run', 'use', 'lean@1'],
|
||||
['show', 'unknown@1'],
|
||||
['preview', '--target', 'unknown-host'],
|
||||
['preview', '--selection', 'eager'],
|
||||
@@ -140,6 +174,7 @@ for (const args of [
|
||||
['preview', '--include', 'skill:missing-workflow'],
|
||||
['preview', '--include', '../../outside'],
|
||||
['preview', '--hooks', 'strict'],
|
||||
['--dry-run', 'preview', '--hooks', 'strict'],
|
||||
['show', '--include', 'skill:security-review'],
|
||||
['explain'],
|
||||
['explain', 'skill:missing-workflow'],
|
||||
|
||||
Reference in new issue
Block a user