Skip to content

Lightpanda: the headless browser designed for AI and automation

test_runner: no trailing blank line after the summary

Adrià Arrufat4cd522c58ac0
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 {