std: fix bitrotted evented code
parent
6ae36807b7
commit
5b10d9f917
|
@ -267,17 +267,16 @@ pub fn Channel(comptime T: type) type {
|
|||
}
|
||||
|
||||
test "std.event.Channel" {
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
// https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
|
||||
// https://github.com/ziglang/zig/issues/3251
|
||||
if (builtin.os == .freebsd) return error.SkipZigTest;
|
||||
|
||||
// TODO provide a way to run tests in evented I/O mode
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
var channel: Channel(i32) = undefined;
|
||||
channel.init([0]i32{});
|
||||
channel.init(&[0]i32{});
|
||||
defer channel.deinit();
|
||||
|
||||
var handle = async testChannelGetter(&channel);
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn Group(comptime ReturnType: type) type {
|
|||
const AllocStack = std.atomic.Stack(Node);
|
||||
|
||||
pub const Node = struct {
|
||||
bytes: []const u8 = [0]u8{},
|
||||
bytes: []const u8 = &[0]u8{},
|
||||
handle: anyframe->ReturnType,
|
||||
};
|
||||
|
||||
|
|
|
@ -117,21 +117,21 @@ pub const Lock = struct {
|
|||
};
|
||||
|
||||
test "std.event.Lock" {
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
// TODO https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
|
||||
// TODO https://github.com/ziglang/zig/issues/3251
|
||||
if (builtin.os == .freebsd) return error.SkipZigTest;
|
||||
|
||||
// TODO provide a way to run tests in evented I/O mode
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
var lock = Lock.init();
|
||||
defer lock.deinit();
|
||||
|
||||
_ = async testLock(&lock);
|
||||
|
||||
testing.expectEqualSlices(i32, [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len, shared_test_data);
|
||||
const expected_result = [1]i32{3 * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
|
||||
testing.expectEqualSlices(i32, &expected_result, &shared_test_data);
|
||||
}
|
||||
|
||||
async fn testLock(lock: *Lock) void {
|
||||
|
|
|
@ -615,12 +615,11 @@ pub fn Watch(comptime V: type) type {
|
|||
const test_tmp_dir = "std_event_fs_test";
|
||||
|
||||
test "write a file, watch it, write it again" {
|
||||
// TODO provide a way to run tests in evented I/O mode
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
// TODO re-enable this test
|
||||
if (true) return error.SkipZigTest;
|
||||
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
// TODO move this into event loop too
|
||||
try os.makePath(allocator, test_tmp_dir);
|
||||
defer os.deleteTree(test_tmp_dir) catch {};
|
||||
|
||||
|
|
|
@ -81,17 +81,15 @@ test "resolve DNS" {
|
|||
}
|
||||
|
||||
test "listen on a port, send bytes, receive bytes" {
|
||||
if (!std.io.is_async) return error.SkipZigTest;
|
||||
|
||||
if (std.builtin.os != .linux) {
|
||||
// TODO build abstractions for other operating systems
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
if (std.io.mode != .evented) {
|
||||
// TODO add ability to run tests in non-blocking I/O mode
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
// TODO doing this at comptime crashed the compiler
|
||||
const localhost = net.Address.parseIp("127.0.0.1", 0);
|
||||
const localhost = try net.Address.parseIp("127.0.0.1", 0);
|
||||
|
||||
var server = net.StreamServer.init(net.StreamServer.Options{});
|
||||
defer server.deinit();
|
||||
|
|
Loading…
Reference in New Issue