Merge pull request #2739 from gsd-build/fix/2732-graphify-cli-invocation
fix(graphify): update CLI invocation from legacy flag form to subcommand
This commit is contained in:
@@ -384,18 +384,41 @@ describe('checkGraphifyVersion', () => {
|
||||
assert.ok(result.warning.includes('Could not parse'));
|
||||
});
|
||||
|
||||
test('calls python3 with importlib.metadata', () => {
|
||||
let capturedCmd;
|
||||
let capturedArgs;
|
||||
test('tries graphify --version first before python3', () => {
|
||||
const calls = [];
|
||||
mock.method(childProcess, 'spawnSync', (cmd, args) => {
|
||||
capturedCmd = cmd;
|
||||
capturedArgs = args;
|
||||
calls.push({ cmd, args });
|
||||
return { status: 0, stdout: '0.4.3\n', stderr: '', error: undefined, signal: null };
|
||||
});
|
||||
|
||||
checkGraphifyVersion();
|
||||
assert.strictEqual(capturedCmd, 'python3');
|
||||
assert.ok(capturedArgs.some(arg => arg.includes('importlib.metadata')));
|
||||
assert.strictEqual(calls.length, 1, 'exactly one spawnSync call — no python3 fallback');
|
||||
assert.strictEqual(calls[0].cmd, 'graphify');
|
||||
assert.ok(calls[0].args.includes('--version'), 'graphify called with --version');
|
||||
const python3Calls = calls.filter(c => c.cmd === 'python3');
|
||||
assert.strictEqual(python3Calls.length, 0, 'no python3 fallback when graphify --version succeeds');
|
||||
});
|
||||
|
||||
test('falls back to python3 importlib.metadata when graphify --version fails', () => {
|
||||
const calls = [];
|
||||
mock.method(childProcess, 'spawnSync', (cmd, args) => {
|
||||
calls.push({ cmd, args });
|
||||
if (cmd === 'graphify') {
|
||||
return { status: 1, stdout: '', stderr: 'unknown option', error: undefined, signal: null };
|
||||
}
|
||||
// python3 fallback
|
||||
return { status: 0, stdout: '0.4.3\n', stderr: '', error: undefined, signal: null };
|
||||
});
|
||||
|
||||
const result = checkGraphifyVersion();
|
||||
assert.strictEqual(result.version, '0.4.3');
|
||||
assert.strictEqual(result.compatible, true);
|
||||
assert.ok(calls.length >= 2, 'at least two spawnSync calls (graphify attempt + python3 fallback)');
|
||||
assert.strictEqual(calls[0].cmd, 'graphify', 'graphify call precedes python3 fallback');
|
||||
assert.ok(calls[0].args.includes('--version'), 'graphify --version attempted first');
|
||||
const lastCall = calls[calls.length - 1];
|
||||
assert.strictEqual(lastCall.cmd, 'python3', 'python3 fallback fires last');
|
||||
assert.ok(lastCall.args.some(arg => arg.includes('importlib.metadata')));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user