Skip to content

Commit 36b2670

Browse files
committed
test(cli): carry the vitest list child's status and output in #18788 pin failures
Every case in hook-timeout-override-refusal.test.ts asserts a child's exit code, so a dead child read only as `expected 1 to be +0`. Each status assertion now carries the exit status and the bounded head of the child's output, where a config-load failure prints its cause. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01REwoooZ6nXESkVCEtsbeRC
1 parent 0a69482 commit 36b2670

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

‎packages/cli/test/hook-timeout-override-refusal.test.ts‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,32 @@ function runVitestList(...flags: string[]): ChildRun {
165165
}
166166
}
167167

168+
/** How much of a child's output a failed status assertion carries. */
169+
const REPORTED_OUTPUT_CHARS = 2_000;
170+
171+
/**
172+
* The message every status assertion here carries: the child's exit status and
173+
* the head of what it printed (#26047).
174+
*
175+
* Each case asserts a child's exit code, so any death of the child reads as
176+
* `expected 1 to be +0` and nothing else. Three merge-queue builds failed the
177+
* no-override control with exactly that line and no way to tell a refusal, a
178+
* config-load crash and a timeout apart. The head is kept because a config-load
179+
* failure prints its cause first (`failed to load config from …` and the
180+
* thrown error), and the length is bounded so a listing of the whole package
181+
* cannot flood the report.
182+
*/
183+
function describeRun(run: ChildRun): string {
184+
const head = run.output.slice(0, REPORTED_OUTPUT_CHARS);
185+
const cut = run.output.length > head.length ? `\n… (${run.output.length - head.length} more chars)` : '';
186+
return `vitest list exited ${run.status}; its output began:\n${head}${cut}`;
187+
}
188+
168189
describe('#18788 a CLI timeout override that cannot reach a project is refused, not passed', () => {
169190
it('refuses `--hookTimeout`, naming the package and a spelling that does bite', () => {
170191
const run = runVitestList('--hookTimeout=1');
171192

172-
expect(run.status).not.toBe(0);
193+
expect(run.status, describeRun(run)).not.toBe(0);
173194
expect(run.output).toContain(REFUSAL);
174195
expect(run.output).toContain('--hookTimeout');
175196
// The #17978 finding against the sibling preflight, held here too: a shared
@@ -185,7 +206,7 @@ describe('#18788 a CLI timeout override that cannot reach a project is refused,
185206
it('refuses `--teardownTimeout` — the other knob the same allowlist drops', () => {
186207
const run = runVitestList('--teardownTimeout=1');
187208

188-
expect(run.status).not.toBe(0);
209+
expect(run.status, describeRun(run)).not.toBe(0);
189210
expect(run.output).toContain(REFUSAL);
190211
expect(run.output).toContain('--teardownTimeout');
191212
}, VITEST_LIST_BUDGET_MS);
@@ -195,7 +216,7 @@ describe('#18788 a CLI timeout override that cannot reach a project is refused,
195216
// everything, which would be a worse defect than the one being fixed.
196217
const run = runVitestList();
197218

198-
expect(run.status).toBe(0);
219+
expect(run.status, describeRun(run)).toBe(0);
199220
expect(run.output).not.toContain(REFUSAL);
200221
// It really listed something, so the zero is a reading and not an empty run.
201222
expect(run.output).toMatch(/\.test\.ts/);
@@ -209,7 +230,7 @@ describe('#18788 a CLI timeout override that cannot reach a project is refused,
209230
// question.
210231
const run = runVitestList('--testTimeout=1');
211232

212-
expect(run.status).toBe(0);
233+
expect(run.status, describeRun(run)).toBe(0);
213234
expect(run.output).not.toContain(REFUSAL);
214235
}, VITEST_LIST_BUDGET_MS);
215236
});

0 commit comments

Comments
 (0)