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