From 797408f2145de84caff960d7133e4f3d398936a3 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 5 Sep 2026 09:54:30 +0000 Subject: [PATCH 1/3] test: run the --bail JUnit regression tests concurrently and assert the full report Both tests in test/regression/issue/26851.test.ts spawn their own bun test child in their own tempDir. Run them with test.concurrent so the two children overlap. Assert the whole JUnit document with an inline snapshot (time and hostname normalized), the bail line and the summary line on stderr, and exit code 1. Add a test after the failure and a third test file to show that --bail stops the run and that the report only holds what ran. --- test/regression/issue/26851.test.ts | 124 ++++++++++++++++------------ 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/test/regression/issue/26851.test.ts b/test/regression/issue/26851.test.ts index c3a07909788e..8f8c160e1ba4 100644 --- a/test/regression/issue/26851.test.ts +++ b/test/regression/issue/26851.test.ts @@ -1,77 +1,91 @@ +// https://github.com/oven-sh/bun/issues/26851 +// `bun test --bail --reporter=junit --reporter-outfile=` must still write +// the JUnit file when --bail stops the run. import { expect, test } from "bun:test"; -import { bunEnv, bunExe, tempDir } from "harness"; +import { bunEnv, bunExe, normalizeBunSnapshot, tempDir } from "harness"; import { join } from "path"; -test("--bail writes JUnit reporter outfile", async () => { - using dir = tempDir("bail-junit", { - "fail.test.ts": ` - import { test, expect } from "bun:test"; - test("failing test", () => { expect(1).toBe(2); }); - `, - }); +const passing = (name: string) => + `import { test, expect } from "bun:test";\ntest(${JSON.stringify(name)}, () => { expect(1).toBe(1); });\n`; +const failing = (name: string) => + `import { test, expect } from "bun:test";\ntest(${JSON.stringify(name)}, () => { expect(1).toBe(2); });\n`; - const outfile = join(String(dir), "results.xml"); +// The hostname and the time attributes differ per run. Everything else is stable. +function normalizeJUnit(xml: string) { + return xml.replace(/ time="[^"]*"/g, ' time="