| ... | ... | @@ -31,11 +31,14 @@ pub fn main() void { |
| 31 | 31 | var ok_count: usize = 0; |
| 32 | 32 | var skip_count: usize = 0; |
| 33 | 33 | var fail_count: usize = 0; |
| 34 | | var progress = std.Progress{}; |
| 34 | var progress = std.Progress{ |
| 35 | .dont_print_on_dumb = true, |
| 36 | }; |
| 35 | 37 | const root_node = progress.start("Test", test_fn_list.len) catch |err| switch (err) { |
| 36 | 38 | // TODO still run tests in this case |
| 37 | 39 | error.TimerUnsupported => @panic("timer unsupported"), |
| 38 | 40 | }; |
| 41 | const have_tty = progress.terminal != null and progress.supports_ansi_escape_codes; |
| 39 | 42 | |
| 40 | 43 | var async_frame_buffer: []align(std.Target.stack_align) u8 = undefined; |
| 41 | 44 | // TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly |
| ... | ... | @@ -55,7 +58,7 @@ pub fn main() void { |
| 55 | 58 | var test_node = root_node.start(test_fn.name, 0); |
| 56 | 59 | test_node.activate(); |
| 57 | 60 | progress.refresh(); |
| 58 | | if (progress.terminal == null) { |
| 61 | if (!have_tty) { |
| 59 | 62 | std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name }); |
| 60 | 63 | } |
| 61 | 64 | const result = if (test_fn.async_frame_size) |size| switch (io_mode) { |
| ... | ... | @@ -71,26 +74,26 @@ pub fn main() void { |
| 71 | 74 | skip_count += 1; |
| 72 | 75 | test_node.end(); |
| 73 | 76 | progress.log("{s}... SKIP (async test)\n", .{test_fn.name}); |
| 74 | | if (progress.terminal == null) std.debug.print("SKIP (async test)\n", .{}); |
| 77 | if (!have_tty) std.debug.print("SKIP (async test)\n", .{}); |
| 75 | 78 | continue; |
| 76 | 79 | }, |
| 77 | 80 | } else test_fn.func(); |
| 78 | 81 | if (result) |_| { |
| 79 | 82 | ok_count += 1; |
| 80 | 83 | test_node.end(); |
| 81 | | if (progress.terminal == null) std.debug.print("OK\n", .{}); |
| 84 | if (!have_tty) std.debug.print("OK\n", .{}); |
| 82 | 85 | } else |err| switch (err) { |
| 83 | 86 | error.SkipZigTest => { |
| 84 | 87 | skip_count += 1; |
| 85 | 88 | test_node.end(); |
| 86 | 89 | progress.log("{s}... SKIP\n", .{test_fn.name}); |
| 87 | | if (progress.terminal == null) std.debug.print("SKIP\n", .{}); |
| 90 | if (!have_tty) std.debug.print("SKIP\n", .{}); |
| 88 | 91 | }, |
| 89 | 92 | else => { |
| 90 | 93 | fail_count += 1; |
| 91 | 94 | test_node.end(); |
| 92 | 95 | progress.log("{s}... FAIL ({s})\n", .{ test_fn.name, @errorName(err) }); |
| 93 | | if (progress.terminal == null) std.debug.print("FAIL ({s})\n", .{@errorName(err)}); |
| 96 | if (!have_tty) std.debug.print("FAIL ({s})\n", .{@errorName(err)}); |
| 94 | 97 | if (@errorReturnTrace()) |trace| { |
| 95 | 98 | std.debug.dumpStackTrace(trace.*); |
| 96 | 99 | } |