authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-26 19:36:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-26 21:58:19-07:00
logf2e8c79763723e394f57af84af977d91652568b5
treeb2b86f4103cc46b361d8df37da49cdc5bef78346
parent5a8b6149fb0f09d4e221f482b1de225f76bd1840

std.Progress.log: adjust API

Now it will fall back to std.debug.print if there is no tty.

2 files changed, 4 insertions(+), 4 deletions(-)

lib/std/Progress.zig+4-1
...@@ -297,7 +297,10 @@ fn refreshWithHeldLock(self: *Progress) void {...@@ -297,7 +297,10 @@ fn refreshWithHeldLock(self: *Progress) void {
297}297}
298298
299pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void {299pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void {
300 const file = self.terminal orelse return;300 const file = self.terminal orelse {
301 std.debug.print(format, args);
302 return;
303 };
301 self.refresh();304 self.refresh();
302 file.writer().print(format, args) catch {305 file.writer().print(format, args) catch {
303 self.terminal = null;306 self.terminal = null;
lib/test_runner.zig-3
...@@ -74,7 +74,6 @@ pub fn main() void {...@@ -74,7 +74,6 @@ pub fn main() void {
74 skip_count += 1;74 skip_count += 1;
75 test_node.end();75 test_node.end();
76 progress.log("SKIP (async test)\n", .{});76 progress.log("SKIP (async test)\n", .{});
77 if (!have_tty) std.debug.print("SKIP (async test)\n", .{});
78 continue;77 continue;
79 },78 },
80 } else test_fn.func();79 } else test_fn.func();
...@@ -86,13 +85,11 @@ pub fn main() void {...@@ -86,13 +85,11 @@ pub fn main() void {
86 error.SkipZigTest => {85 error.SkipZigTest => {
87 skip_count += 1;86 skip_count += 1;
88 progress.log("SKIP\n", .{});87 progress.log("SKIP\n", .{});
89 if (!have_tty) std.debug.print("SKIP\n", .{});
90 test_node.end();88 test_node.end();
91 },89 },
92 else => {90 else => {
93 fail_count += 1;91 fail_count += 1;
94 progress.log("FAIL ({s})\n", .{@errorName(err)});92 progress.log("FAIL ({s})\n", .{@errorName(err)});
95 if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)});
96 if (@errorReturnTrace()) |trace| {93 if (@errorReturnTrace()) |trace| {
97 std.debug.dumpStackTrace(trace.*);94 std.debug.dumpStackTrace(trace.*);
98 }95 }