authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-08 16:24:26-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-08 16:24:26-05:00
log5b10d9f917ac773ca7c842d74ef44c861484670f
treec7d02b0f0c67f8f933ff66e88f62f476af5841ca
parent6ae36807b70e741ac1a7f8ee1b8d90466abfdda8
signaturelock-open Commit is signed but in an unrecognized format.

std: fix bitrotted evented code


5 files changed, 13 insertions(+), 17 deletions(-)

lib/std/event/channel.zig+3-4
......@@ -267,17 +267,16 @@ pub fn Channel(comptime T: type) type {
267267}
268268
269269test "std.event.Channel" {
270 if (!std.io.is_async) return error.SkipZigTest;
271
270272 // https://github.com/ziglang/zig/issues/1908
271273 if (builtin.single_threaded) return error.SkipZigTest;
272274
273275 // https://github.com/ziglang/zig/issues/3251
274276 if (builtin.os == .freebsd) return error.SkipZigTest;
275277
276 // TODO provide a way to run tests in evented I/O mode
277 if (!std.io.is_async) return error.SkipZigTest;
278
279278 var channel: Channel(i32) = undefined;
280 channel.init([0]i32{});
279 channel.init(&[0]i32{});
281280 defer channel.deinit();
282281
283282 var handle = async testChannelGetter(&channel);
lib/std/event/group.zig+1-1
......@@ -22,7 +22,7 @@ pub fn Group(comptime ReturnType: type) type {
2222 const AllocStack = std.atomic.Stack(Node);
2323
2424 pub const Node = struct {
25 bytes: []const u8 = [0]u8{},
25 bytes: []const u8 = &[0]u8{},
2626 handle: anyframe->ReturnType,
2727 };
2828
lib/std/event/lock.zig+4-4
......@@ -117,21 +117,21 @@ pub const Lock = struct {
117117};
118118
119119test "std.event.Lock" {
120 if (!std.io.is_async) return error.SkipZigTest;
121
120122 // TODO https://github.com/ziglang/zig/issues/1908
121123 if (builtin.single_threaded) return error.SkipZigTest;
122124
123125 // TODO https://github.com/ziglang/zig/issues/3251
124126 if (builtin.os == .freebsd) return error.SkipZigTest;
125127
126 // TODO provide a way to run tests in evented I/O mode
127 if (!std.io.is_async) return error.SkipZigTest;
128
129128 var lock = Lock.init();
130129 defer lock.deinit();
131130
132131 _ = async testLock(&lock);
133132
134 testing.expectEqualSlices(i32, [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len, shared_test_data);
133 const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
134 testing.expectEqualSlices(i32, &expected_result, &shared_test_data);
135135}
136136
137137async fn testLock(lock: *Lock) void {
lib/std/fs/watch.zig+2-3
......@@ -615,12 +615,11 @@ pub fn Watch(comptime V: type) type {
615615const test_tmp_dir = "std_event_fs_test";
616616
617617test "write a file, watch it, write it again" {
618 // TODO provide a way to run tests in evented I/O mode
619 if (!std.io.is_async) return error.SkipZigTest;
618 // TODO re-enable this test
619 if (true) return error.SkipZigTest;
620620
621621 const allocator = std.heap.page_allocator;
622622
623 // TODO move this into event loop too
624623 try os.makePath(allocator, test_tmp_dir);
625624 defer os.deleteTree(test_tmp_dir) catch {};
626625
lib/std/net/test.zig+3-5
......@@ -81,17 +81,15 @@ test "resolve DNS" {
8181}
8282
8383test "listen on a port, send bytes, receive bytes" {
84 if (!std.io.is_async) return error.SkipZigTest;
85
8486 if (std.builtin.os != .linux) {
8587 // TODO build abstractions for other operating systems
8688 return error.SkipZigTest;
8789 }
88 if (std.io.mode != .evented) {
89 // TODO add ability to run tests in non-blocking I/O mode
90 return error.SkipZigTest;
91 }
9290
9391 // TODO doing this at comptime crashed the compiler
94 const localhost = net.Address.parseIp("127.0.0.1", 0);
92 const localhost = try net.Address.parseIp("127.0.0.1", 0);
9593
9694 var server = net.StreamServer.init(net.StreamServer.Options{});
9795 defer server.deinit();