fix(run): keep failing tests and their failures in the test tree (#8203)

JVM test names were cut at their first parenthesis, so Kotlin tests like `parse (valid input)` and `parse (empty input)`, Spock features and the tests the JUnit runner reports merged into one node `parse` with one gutter icon, and Rerun Failed asked for `ParserTest.parse`, which Gradle and Surefire don't match. Now only a parameter-type list right after the method name (and an invocation's index) is dropped (jvmMethodName / junit::method_name), consistently in the test tree, JUnit XML report names, rerun filters and the gutter's pass/fail icons (JVM files only; pytest and .NET names keep the old rule).

A test that printed more than 400 lines lost its failure, because the tree kept the first 400 lines. Failure details are now kept apart from printed output and never cut; long printed output keeps its first 100 and last 300-600 lines with a line counting those left out. JUnit XML output is no longer cut at 200 lines.

Co-authored-by: ntbang0901 <[email protected]>
Цей коміт міститься в:
ntbang0901 authored and GitHub committed 2026-12-05 18:14:52 +08:00
1 джерело 838cf14845
коміт 529cd33ddc
16 files changed
+351 -35

No files matched your search

+47 -2
Переглянути файл
@@ -619,7 +619,7 @@ describe("JUnit XML reports", () => {
},
]);
expect(events[0]).toEqual({ type: "result", path: ["a.B", "ok"], status: "passed", durationMs: 3 });
expect(events).toContainEqual({ type: "output", path: ["a.B$Inner", "bad"], line: "expected 1" });
expect(events).toContainEqual({ type: "output", path: ["a.B$Inner", "bad"], line: "expected 1", failure: true });
expect(events).toContainEqual({
type: "location",
path: ["a.B$Inner", "bad"],
@@ -692,7 +692,7 @@ describe("what JUnit XML reports say a test printed", () => {
r.apply(
parser.feed("##teamcity[testFinished name='later()' className='a.B' reportName='later (not yet)' duration='0']"),
);
applyTestReports(r, [report({ name: "ok" }), report({ name: "later", status: "skipped" })]);
applyTestReports(r, [report({ name: "ok" }), report({ name: "later (not yet)", status: "skipped" })]);
expect(r.counts()).toMatchObject({ total: 2, passed: 1, skipped: 1 });
expect(r.roots[0]?.children.map((n) => n.path)).toEqual([
["a.B", "ok"],
@@ -700,6 +700,25 @@ describe("what JUnit XML reports say a test printed", () => {
]);
});
it("matches Kotlin tests named with parentheses to their own XML cases", () => {
const r = new TestResults();
const parser = jvmParser();
for (const name of ["parse (empty input)", "parse (valid input)"]) {
const own = `name='${name}()' className='a.B' reportName='${name}()'`;
r.apply(parser.feed(`##teamcity[testStarted ${own}]`));
if (name.includes("empty")) r.apply(parser.feed(`##teamcity[testFailed ${own} message='no' details='no']`));
r.apply(parser.feed(`##teamcity[testFinished ${own} duration='1']`));
}
// The names ide-run's report parser gives Gradle's `parse (empty input)()` and `parse (valid input)()`.
applyTestReports(r, [
report({ name: "parse (empty input)", status: "failed", stdout: "printed by empty" }),
report({ name: "parse (valid input)", stdout: "printed by valid" }),
]);
expect(r.counts()).toMatchObject({ total: 2, passed: 1, failed: 1 });
expect(output(r, "parse (empty input)")).toEqual(["printed by empty", "no"]);
expect(output(r, "parse (valid input)")).toEqual(["printed by valid"]);
});
it("does not add display-name rows beside parameterized Gradle invocations", () => {
const r = new TestResults();
const parser = jvmParser();
@@ -779,6 +798,32 @@ describe("what JUnit XML reports say a test printed", () => {
expect(output(r, "bad")).toEqual(["bad says hi", "Error: boom"]);
});
it("keeps the start and the end of long printed output, and the whole failure", () => {
const r = new TestResults();
const stdout = Array.from({ length: 1000 }, (_, i) => `line ${i}`);
const trace = ["AssertionError: no", ...Array.from({ length: 250 }, (_, i) => `\tat a.B.f${i}(B.java:${i + 1})`)];
applyTestReports(r, [
report({ name: "bad", status: "failed", message: "no", output: trace.join("\n"), stdout: stdout.join("\n") }),
]);
const lines = output(r, "bad")!;
expect(lines.slice(0, 2)).toEqual(["line 0", "line 1"]);
expect(lines.find((l) => l.startsWith("… "))).toMatch(/^… [\d,]+ lines not shown …$/);
expect(lines.slice(-trace.length - 2)).toEqual(["line 999", "no", ...trace]);
});
it("is not repeated for a test whose long output the Gradle init script reported", () => {
const r = new TestResults();
const path = ["a.B", "ok"];
const printed = Array.from({ length: 1000 }, (_, i) => `line ${i}`);
r.apply([
...printed.map((line) => ({ type: "output" as const, path, line })),
{ type: "result", path, status: "passed" },
]);
const shown = [...output(r, "ok")!];
applyTestReports(r, [report({ name: "ok", stdout: printed.join("\n") })]);
expect(output(r, "ok")).toEqual(shown);
});
it("is not repeated for tests the Gradle init script reported with their output", () => {
const r = new TestResults();
r.apply([