Merge branch 'kristate-skippable-tests-issue1274'

This commit is contained in:
Andrew Kelley 2018-07-21 23:44:17 -04:00
commit 0a32f80d9a
2 changed files with 19 additions and 4 deletions

View File

@ -125,8 +125,9 @@ pub async fn connect(loop: *Loop, _address: *const std.net.Address) !std.os.File
test "listen on a port, send bytes, receive bytes" {
if (builtin.os != builtin.Os.linux) {
// TODO build abstractions for other operating systems
return;
return error.SkipZigTest;
}
const MyServer = struct {
tcp_server: Server,

View File

@ -5,11 +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);
try test_fn.func();
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);
}
}