From a39fa8fac6d1fe5a86c29f804e44594e0b699ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Thu, 17 Sep 2026 17:36:32 +0200 Subject: [PATCH 1/3] test_runner: keep unnamed refAllDecls tests out of the slowest list The Zig 0.16 port of SlowTracker.endTiming dropped the early return for unnamed tests and discarded the flag, so the refAllDecls blocks were timed and queued like real tests. With a filter that matches nothing they were the only candidates and filled the "Slowest 5 tests" output. --- src/test_runner.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test_runner.zig b/src/test_runner.zig index 928986aca..5e56afcaa 100644 --- a/src/test_runner.zig +++ b/src/test_runner.zig @@ -345,7 +345,9 @@ const SlowTracker = struct { const start = self.start; self.start = timestamp; const ns: u64 = @intCast(start.durationTo(timestamp).toNanoseconds()); - _ = is_unnamed_test; + if (is_unnamed_test) { + return ns; + } var slowest = &self.slowest; From 5bcea2fc831dd732466e7695e690c0477482fdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Thu, 17 Sep 2026 17:37:48 +0200 Subject: [PATCH 2/3] test_runner: skip the slowest-tests block when nothing was timed --- src/test_runner.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test_runner.zig b/src/test_runner.zig index 5e56afcaa..efacf13e3 100644 --- a/src/test_runner.zig +++ b/src/test_runner.zig @@ -233,8 +233,7 @@ const Runner = struct { } Printer.fmt("\n", .{}); - try slowest.display(); - Printer.fmt("\n", .{}); + slowest.display(); // stats if (self.env.metrics) { const stdout = std.Io.File.stdout(); @@ -374,14 +373,18 @@ const SlowTracker = struct { return ns; } - fn display(self: *SlowTracker) !void { + fn display(self: *SlowTracker) void { var slowest = self.slowest; const count = slowest.count(); + if (count == 0) { + return; + } Printer.fmt("Slowest {d} test{s}: \n", .{ count, if (count != 1) "s" else "" }); while (slowest.popMin()) |info| { const ms = @as(f64, @floatFromInt(info.ns)) / 1_000_000.0; Printer.fmt(" {d:.2}ms\t{s}\n", .{ ms, info.name }); } + Printer.fmt("\n", .{}); } fn compareTiming(context: void, a: TestInfo, b: TestInfo) std.math.Order { From 4cd522c58ac0f59db92c1ac2aee79e77c0dc8936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Thu, 17 Sep 2026 17:42:21 +0200 Subject: [PATCH 3/3] test_runner: no trailing blank line after the summary Each optional block after the pass count (slowest list, metrics JSON, failed-test summary) now prints its own leading separator instead of the previous block printing a trailing one, so the output never ends with an empty line. Printer.status places the color reset before a trailing newline so the escape sequence no longer opens the next line. --- src/test_runner.zig | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test_runner.zig b/src/test_runner.zig index efacf13e3..a4a83a240 100644 --- a/src/test_runner.zig +++ b/src/test_runner.zig @@ -231,11 +231,11 @@ const Runner = struct { if (leak > 0) { Printer.status(.fail, "{d} test{s} leaked\n", .{ leak, if (leak != 1) "s" else "" }); } - Printer.fmt("\n", .{}); slowest.display(); // stats if (self.env.metrics) { + Printer.fmt("\n", .{}); const stdout = std.Io.File.stdout(); var writer = stdout.writerStreaming(io, &.{}); const stats = self.ta.stats(); @@ -257,11 +257,10 @@ const Runner = struct { } if (fail_list.items.len > 0) { - Printer.status(.fail, "Failed Test Summary: \n", .{}); + Printer.status(.fail, "\nFailed Test Summary: \n", .{}); for (fail_list.items) |name| { Printer.status(.fail, "- {s}\n", .{name}); } - Printer.fmt("\n", .{}); } std.process.exit(if (fail == 0) 0 else 1); @@ -295,7 +294,13 @@ const Printer = struct { .skip => std.debug.print("\x1b[33m", .{}), else => {}, } - std.debug.print(format ++ "\x1b[0m", args); + // Reset before a trailing newline so the escape never starts the next line. + const reset = "\x1b[0m"; + if (comptime std.mem.endsWith(u8, format, "\n")) { + std.debug.print(format[0 .. format.len - 1] ++ reset ++ "\n", args); + } else { + std.debug.print(format ++ reset, args); + } } }; @@ -379,12 +384,11 @@ const SlowTracker = struct { if (count == 0) { return; } - Printer.fmt("Slowest {d} test{s}: \n", .{ count, if (count != 1) "s" else "" }); + Printer.fmt("\nSlowest {d} test{s}: \n", .{ count, if (count != 1) "s" else "" }); while (slowest.popMin()) |info| { const ms = @as(f64, @floatFromInt(info.ns)) / 1_000_000.0; Printer.fmt(" {d:.2}ms\t{s}\n", .{ ms, info.name }); } - Printer.fmt("\n", .{}); } fn compareTiming(context: void, a: TestInfo, b: TestInfo) std.math.Order {