rename error.skip to error.SkipZigTest
also print stats at the end of test runner
This commit is contained in:
parent
44292721bf
commit
4d9964a457
|
@ -123,15 +123,9 @@ pub async fn connect(loop: *Loop, _address: *const std.net.Address) !std.os.File
|
|||
}
|
||||
|
||||
test "listen on a port, send bytes, receive bytes" {
|
||||
// TODO build abstractions for other operating systems
|
||||
const skip_test: bool = switch (builtin.os) {
|
||||
builtin.Os.linux => false,
|
||||
//builtin.Os.macosx, builtin.Os.ios => false,
|
||||
else => true,
|
||||
};
|
||||
|
||||
if (skip_test == true) {
|
||||
return error.skip;
|
||||
if (builtin.os != builtin.Os.linux) {
|
||||
// TODO build abstractions for other operating systems
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const MyServer = struct {
|
||||
|
|
|
@ -5,17 +5,25 @@ const test_fn_list = builtin.__zig_test_fn_slice;
|
|||
const warn = std.debug.warn;
|
||||
|
||||
pub fn main() !void {
|
||||
var ok_count: usize = 0;
|
||||
var skip_count: usize = 0;
|
||||
for (test_fn_list) |test_fn, i| {
|
||||
warn("Test {}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
|
||||
|
||||
test_fn.func() catch |err| {
|
||||
if (err == error.skip) {
|
||||
warn("SKIPPED\n");
|
||||
continue;
|
||||
}
|
||||
return err;
|
||||
};
|
||||
|
||||
warn("OK\n");
|
||||
if (test_fn.func()) |_| {
|
||||
ok_count += 1;
|
||||
warn("OK\n");
|
||||
} else |err| switch (err) {
|
||||
error.SkipZigTest => {
|
||||
skip_count += 1;
|
||||
warn("SKIP\n");
|
||||
},
|
||||
else => return err,
|
||||
}
|
||||
}
|
||||
if (ok_count == test_fn_list.len) {
|
||||
warn("All tests passed.\n");
|
||||
} else {
|
||||
warn("{} passed; {} skipped.\n", ok_count, skip_count);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user