mirror of https://github.com/garrytan/gstack.git
Merge 158d7c95d6 into c43c850cae
This commit is contained in:
commit
e26318bd3d
|
|
@ -88,6 +88,20 @@ function parseProviders(s: string | undefined): Array<'claude' | 'gpt' | 'gemini
|
||||||
return seen.size ? Array.from(seen) : ['claude'];
|
return seen.size ? Array.from(seen) : ['claude'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parsePositiveIntegerFlag(name: string, def: string): number {
|
||||||
|
const raw = arg(name, def);
|
||||||
|
if (!raw || !/^\+?[1-9]\d*$/.test(raw)) {
|
||||||
|
console.error(`${name} requires a positive integer`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const parsed = Number(raw);
|
||||||
|
if (!Number.isSafeInteger(parsed)) {
|
||||||
|
console.error(`${name} requires a positive integer`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
function resolvePrompt(positional: string | undefined): string {
|
function resolvePrompt(positional: string | undefined): string {
|
||||||
const inline = arg('--prompt');
|
const inline = arg('--prompt');
|
||||||
if (inline) return inline;
|
if (inline) return inline;
|
||||||
|
|
@ -107,7 +121,7 @@ async function main(): Promise<void> {
|
||||||
const prompt = resolvePrompt(positional);
|
const prompt = resolvePrompt(positional);
|
||||||
const providers = parseProviders(arg('--models'));
|
const providers = parseProviders(arg('--models'));
|
||||||
const workdir = arg('--workdir', process.cwd())!;
|
const workdir = arg('--workdir', process.cwd())!;
|
||||||
const timeoutMs = parseInt(arg('--timeout-ms', '300000')!, 10);
|
const timeoutMs = parsePositiveIntegerFlag('--timeout-ms', '300000');
|
||||||
const output = (arg('--output', 'table') as OutputFormat);
|
const output = (arg('--output', 'table') as OutputFormat);
|
||||||
const skipUnavailable = flag('--skip-unavailable');
|
const skipUnavailable = flag('--skip-unavailable');
|
||||||
const doJudge = flag('--judge');
|
const doJudge = flag('--judge');
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,21 @@ describe('gstack-model-benchmark --dry-run', () => {
|
||||||
expect(r.stdout).toContain('workdir: /tmp');
|
expect(r.stdout).toContain('workdir: /tmp');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('--timeout-ms accepts plus-prefixed positive integers', () => {
|
||||||
|
const r = run(['--prompt', 'hi', '--timeout-ms', '+2500', '--dry-run']);
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
expect(r.stdout).toContain('timeout_ms: 2500');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('--timeout-ms rejects malformed values', () => {
|
||||||
|
for (const value of ['1abc', 'nope', '0', '-1', '1.5', '']) {
|
||||||
|
const r = run(['--prompt', 'hi', '--timeout-ms', value, '--dry-run']);
|
||||||
|
expect(r.status).toBe(1);
|
||||||
|
expect(r.stderr).toContain('--timeout-ms requires a positive integer');
|
||||||
|
expect(r.stdout).toBe('');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('--judge flag reported in dry-run output', () => {
|
test('--judge flag reported in dry-run output', () => {
|
||||||
const r = run(['--prompt', 'hi', '--judge', '--dry-run']);
|
const r = run(['--prompt', 'hi', '--judge', '--dry-run']);
|
||||||
expect(r.status).toBe(0);
|
expect(r.status).toBe(0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue