diff options
| author | Vexu <15308111+Vexu@users.noreply.github.com> | 2019-11-23 22:56:05 +0200 |
|---|---|---|
| committer | Vexu <15308111+Vexu@users.noreply.github.com> | 2019-11-23 22:57:34 +0200 |
| commit | b9ef36094c9ffc522def982c98abcb97cd067761 (patch) | |
| tree | 1e3a1265c7ce8e21f7b2f91213cf3f72e3ff4faa | |
| parent | 6c64f079fa4a80949e0721e112a77a771239752d (diff) | |
| download | zig-b9ef36094c9ffc522def982c98abcb97cd067761.tar.gz zig-b9ef36094c9ffc522def982c98abcb97cd067761.zip | |
re-enable stage2 tests
| -rw-r--r-- | build.zig | 10 | ||||
| -rw-r--r-- | lib/std/event/group.zig | 5 | ||||
| -rw-r--r-- | src-self-hosted/test.zig | 22 | ||||
| -rw-r--r-- | test/stage2/test.zig | 6 |
4 files changed, 23 insertions, 20 deletions
@@ -54,6 +54,7 @@ pub fn build(b: *Builder) !void { var test_stage2 = b.addTest("src-self-hosted/test.zig"); test_stage2.setBuildMode(builtin.Mode.Debug); + test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig"); const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"}); @@ -73,8 +74,7 @@ pub fn build(b: *Builder) !void { const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false; const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false; if (!skip_self_hosted) { - // TODO re-enable this after https://github.com/ziglang/zig/issues/2377 - //test_step.dependOn(&exe.step); + test_step.dependOn(&exe.step); } const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; @@ -98,11 +98,7 @@ pub fn build(b: *Builder) !void { const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests"); test_stage2_step.dependOn(&test_stage2.step); - - // TODO see https://github.com/ziglang/zig/issues/1364 - if (false) { - test_step.dependOn(test_stage2_step); - } + test_step.dependOn(test_stage2_step); var chosen_modes: [4]builtin.Mode = undefined; var chosen_mode_index: usize = 0; diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index 77dd2cd1aa..0f6a892594 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -66,11 +66,10 @@ pub fn Group(comptime ReturnType: type) type { node.* = AllocStack.Node{ .next = undefined, .data = Node{ - .handle = frame, - .bytes = @sliceToBytes((*[1]@Frame(func))(frame)[0..]), + .handle = @asyncCall(frame, {}, func, args), + .bytes = std.mem.asBytes(frame), }, }; - frame.* = async func(args); self.alloc_stack.push(node); } diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 670fc8ad6d..940a8c53b3 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler; var ctx: TestContext = undefined; test "stage2" { + // TODO provide a way to run tests in evented I/O mode + if (!std.io.is_async) return error.SkipZigTest; + try ctx.init(); defer ctx.deinit(); - try @import("../test/stage2/compile_errors.zig").addCases(&ctx); - try @import("../test/stage2/compare_output.zig").addCases(&ctx); + try @import("stage2_tests").addCases(&ctx); - async ctx.run(); + _ = async ctx.run(); } const file1 = "1.zig"; @@ -40,7 +42,7 @@ pub const TestContext = struct { .file_index = std.atomic.Int(usize).init(0), }; - self.zig_compiler = try ZigCompiler.init(); + self.zig_compiler = try ZigCompiler.init(allocator); errdefer self.zig_compiler.deinit(); self.group = std.event.Group(anyerror!void).init(allocator); @@ -75,7 +77,7 @@ pub const TestContext = struct { ) !void { var file_index_buf: [20]u8 = undefined; const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr()); - const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 }); + const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 }); if (std.fs.path.dirname(file1_path)) |dirname| { try std.fs.makePath(allocator, dirname); @@ -108,9 +110,9 @@ pub const TestContext = struct { ) !void { var file_index_buf: [20]u8 = undefined; const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr()); - const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 }); + const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 }); - const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, Target(Target.Native).exeFileExt()); + const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{.Native = {}}).exeFileExt()); if (std.fs.path.dirname(file1_path)) |dirname| { try std.fs.makePath(allocator, dirname); } @@ -141,7 +143,7 @@ pub const TestContext = struct { comp: *Compilation, exe_file: []const u8, expected_output: []const u8, - ) !void { + ) anyerror!void { // TODO this should not be necessary const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file); @@ -150,7 +152,7 @@ pub const TestContext = struct { switch (build_event) { .Ok => { - const argv = []const []const u8{exe_file_2}; + const argv = [_][]const u8{exe_file_2}; // TODO use event loop const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024); switch (child.term) { @@ -186,7 +188,7 @@ pub const TestContext = struct { line: usize, column: usize, text: []const u8, - ) !void { + ) anyerror!void { defer comp.destroy(); const build_event = comp.events.get(); diff --git a/test/stage2/test.zig b/test/stage2/test.zig new file mode 100644 index 0000000000..f4768cd39a --- /dev/null +++ b/test/stage2/test.zig @@ -0,0 +1,6 @@ +const TestContext = @import("../../src-self-hosted/test.zig").TestContext; + +pub fn addCases(ctx: *TestContext) !void { + try @import("compile_errors.zig").addCases(ctx); + try @import("compare_output.zig").addCases(ctx); +} |
