mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 03:06:55 -04:00
Add modified test runner (#1294)
* Add modified test runner * Add test runner to build.zig * Fix build.zig formatting * Merge master runner and changed runner * Restore proper comment * Update test/runner.zig * Update test/runner.zig Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com> * Update test/runner.zig Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com> * Update test/runner.zig Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com> * Update test/runner.zig * Restore deleted line * Restore deleted line * Get rid of padding stuff * Update test/runner.zig * Colors * doColors --------- Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com>
This commit is contained in:
parent
54ab3fc8ed
commit
f9a65a0681
@ -168,7 +168,6 @@ fn mainServer() !void {
|
||||
},
|
||||
};
|
||||
if(!is_fuzz_test) @panic("missed call to std.testing.fuzz");
|
||||
if(log_err_count != 0) @panic("error logs detected");
|
||||
},
|
||||
|
||||
else => {
|
||||
@ -190,7 +189,11 @@ fn mainTerminal() void {
|
||||
.root_name = "Test",
|
||||
.estimated_total_items = test_fn_list.len,
|
||||
});
|
||||
const have_tty = std.io.getStdErr().isTty();
|
||||
const doColors = std.io.getStdErr().supportsAnsiEscapeCodes();
|
||||
const reset = if(doColors) "\x1b[0m" else "";
|
||||
const red = if(doColors) "\x1b[31m" else "";
|
||||
const yellow = if(doColors) "\x1b[33m" else "";
|
||||
const green = if(doColors) "\x1b[32m" else "";
|
||||
|
||||
var async_frame_buffer: []align(builtin.target.stackAlignment()) u8 = undefined;
|
||||
// TODO this is on the next line (using `undefined` above) because otherwise zig incorrectly
|
||||
@ -208,33 +211,22 @@ fn mainTerminal() void {
|
||||
testing.log_level = .warn;
|
||||
|
||||
const test_node = root_node.start(test_fn.name, 0);
|
||||
if(!have_tty) {
|
||||
std.debug.print("{d}/{d} {s}...", .{i + 1, test_fn_list.len, test_fn.name});
|
||||
}
|
||||
|
||||
std.debug.print("{d: >4}/{d: <4} {s:.<65}", .{i + 1, test_fn_list.len, test_fn.name});
|
||||
is_fuzz_test = false;
|
||||
if(test_fn.func()) |_| {
|
||||
ok_count += 1;
|
||||
test_node.end();
|
||||
if(!have_tty) std.debug.print("OK\n", .{});
|
||||
std.debug.print("{s}OK{s}\n", .{green, reset});
|
||||
} else |err| switch(err) {
|
||||
error.SkipZigTest => {
|
||||
skip_count += 1;
|
||||
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", .{});
|
||||
}
|
||||
std.debug.print("{s}SKIP{s}\n", .{yellow, reset});
|
||||
test_node.end();
|
||||
},
|
||||
else => {
|
||||
fail_count += 1;
|
||||
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)});
|
||||
}
|
||||
std.debug.print("{s}FAIL{s}\n{s}:\n", .{red, reset, @errorName(err)});
|
||||
if(@errorReturnTrace()) |trace| {
|
||||
std.debug.dumpStackTrace(trace.*);
|
||||
}
|
||||
@ -258,7 +250,7 @@ fn mainTerminal() void {
|
||||
if(fuzz_count != 0) {
|
||||
std.debug.print("{d} fuzz tests found.\n", .{fuzz_count});
|
||||
}
|
||||
if(leaks != 0 or log_err_count != 0 or fail_count != 0) {
|
||||
if(leaks != 0 or fail_count != 0) {
|
||||
std.process.exit(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user