Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/commands/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3295,10 +3295,12 @@ describe('runDiff', () => {
expect(errs.join('\n')).toContain('different tests');
});

it('--dry-run returns the canned sample fully offline (no credentials, no fetch)', async () => {
// Dry-run must not require credentials or hit the network — it returns a
// canned CliRunDiff so `--dry-run` shows the shape offline.
const diff = await runDiff(
it('--dry-run prints the canned sample fully offline and exits 1 when verdicts differ', async () => {
// Dry-run must not require credentials or hit the network. It still emits a
// canned CliRunDiff so `--dry-run` shows the shape offline, then follows the
// same verdict-change exit contract as the real path.
const out: string[] = [];
const rejection = await runDiff(
{
profile: 'default',
output: 'json',
Expand All @@ -3307,8 +3309,15 @@ describe('runDiff', () => {
runA: 'run_aaa',
runB: 'run_bbb',
},
{ stdout: () => undefined, stderr: () => undefined },
);
{ stdout: line => out.push(line), stderr: () => undefined },
).catch((error: unknown) => error);
expect(rejection).toMatchObject({ exitCode: 1 });
const diff = JSON.parse(out.join('')) as {
runA: { runId: string };
runB: { runId: string };
verdictChanged: boolean;
changedSteps: Array<{ stepIndex: number; statusA: string; statusB: string }>;
};
expect(diff.runA.runId).toBe('run_aaa');
expect(diff.runB.runId).toBe('run_bbb');
expect(diff.verdictChanged).toBe(true);
Expand Down
6 changes: 6 additions & 0 deletions src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3956,6 +3956,12 @@ export async function runDiff(opts: DiffOptions, deps: TestDeps = {}): Promise<C
changedSteps: [{ stepIndex: 2, statusA: 'passed', statusB: 'failed' }],
};
out.print(sample, () => renderRunDiffText(sample));
if (sample.verdictChanged) {
throw new CLIError(
`verdicts differ: ${sample.runA.runId}=${sample.runA.status} vs ${sample.runB.runId}=${sample.runB.status}`,
1,
);
}
return sample;
}

Expand Down
Loading