Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions std/event/tcp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,17 @@ 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;
// 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to use a name such as error.SkipZigTest (open to better suggestions) since this is global and we don't want a user to possibly use this name in their own code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiehuis Thanks!

I thought about that, but if used in user code, wouldn't it be caught before hand?

You bring up a good point and perhaps we could rename it to error.skip_test :-)

}

const MyServer = struct {
tcp_server: Server,

Expand Down
8 changes: 7 additions & 1 deletion std/special/test_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ pub fn main() !void {
for (test_fn_list) |test_fn, i| {
warn("Test {}/{} {}...", i + 1, test_fn_list.len, test_fn.name);

try test_fn.func();
test_fn.func() catch |err| {
if (err == error.skip) {
warn("SKIPPED\n");
continue;
}
return err;
};

warn("OK\n");
}
Expand Down