mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
test runner: update to new std.Progress API
This commit is contained in:
parent
f97c2f28fd
commit
795c5791a9
@ -129,12 +129,11 @@ fn mainTerminal() void {
|
|||||||
var ok_count: usize = 0;
|
var ok_count: usize = 0;
|
||||||
var skip_count: usize = 0;
|
var skip_count: usize = 0;
|
||||||
var fail_count: usize = 0;
|
var fail_count: usize = 0;
|
||||||
var progress = std.Progress{
|
const root_node = std.Progress.start(.{
|
||||||
.dont_print_on_dumb = true,
|
.root_name = "Test",
|
||||||
};
|
.estimated_total_items = test_fn_list.len,
|
||||||
const root_node = progress.start("Test", test_fn_list.len);
|
});
|
||||||
const have_tty = progress.terminal != null and
|
const have_tty = std.io.getStdErr().isTty();
|
||||||
(progress.supports_ansi_escape_codes or progress.is_windows_terminal);
|
|
||||||
|
|
||||||
var async_frame_buffer: []align(builtin.target.stackAlignment()) u8 = undefined;
|
var async_frame_buffer: []align(builtin.target.stackAlignment()) u8 = undefined;
|
||||||
// TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly
|
// TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly
|
||||||
@ -151,11 +150,9 @@ fn mainTerminal() void {
|
|||||||
}
|
}
|
||||||
std.testing.log_level = .warn;
|
std.testing.log_level = .warn;
|
||||||
|
|
||||||
var test_node = root_node.start(test_fn.name, 0);
|
const test_node = root_node.start(test_fn.name, 0);
|
||||||
test_node.activate();
|
|
||||||
progress.refresh();
|
|
||||||
if (!have_tty) {
|
if (!have_tty) {
|
||||||
std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
|
std.debug.print("{d}/{d} {s}...", .{ i + 1, test_fn_list.len, test_fn.name });
|
||||||
}
|
}
|
||||||
if (test_fn.func()) |_| {
|
if (test_fn.func()) |_| {
|
||||||
ok_count += 1;
|
ok_count += 1;
|
||||||
@ -164,12 +161,22 @@ fn mainTerminal() void {
|
|||||||
} else |err| switch (err) {
|
} else |err| switch (err) {
|
||||||
error.SkipZigTest => {
|
error.SkipZigTest => {
|
||||||
skip_count += 1;
|
skip_count += 1;
|
||||||
progress.log("SKIP\n", .{});
|
if (have_tty) {
|
||||||
|
std.debug.print("{d}/{d} {s}...SKIP\n", .{ i + 1, test_fn_list.len, test_fn.name });
|
||||||
|
} else {
|
||||||
|
std.debug.print("SKIP\n", .{});
|
||||||
|
}
|
||||||
test_node.end();
|
test_node.end();
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
fail_count += 1;
|
fail_count += 1;
|
||||||
progress.log("FAIL ({s})\n", .{@errorName(err)});
|
if (have_tty) {
|
||||||
|
std.debug.print("{d}/{d} {s}...FAIL ({s})\n", .{
|
||||||
|
i + 1, test_fn_list.len, test_fn.name, @errorName(err),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
std.debug.print("FAIL ({s})\n", .{@errorName(err)});
|
||||||
|
}
|
||||||
if (@errorReturnTrace()) |trace| {
|
if (@errorReturnTrace()) |trace| {
|
||||||
std.debug.dumpStackTrace(trace.*);
|
std.debug.dumpStackTrace(trace.*);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user