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.
This commit is contained in:
Adrià Arrufat committed 2026-09-17 17:42:21 +02:00
1 parent 5bcea2fc83
commit 4cd522c58a
1 file changed
+10 -6
+10 -6
View File
@@ -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 {