authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-23 22:56:05+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-23 22:57:34+02:00
logb9ef36094c9ffc522def982c98abcb97cd067761
tree1e3a1265c7ce8e21f7b2f91213cf3f72e3ff4faa
parent6c64f079fa4a80949e0721e112a77a771239752d
signaturelock-open Commit is signed but in an unrecognized format.

re-enable stage2 tests


4 files changed, 23 insertions(+), 20 deletions(-)

build.zig+3-7
......@@ -54,6 +54,7 @@ pub fn build(b: *Builder) !void {
5454
5555 var test_stage2 = b.addTest("src-self-hosted/test.zig");
5656 test_stage2.setBuildMode(builtin.Mode.Debug);
57 test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig");
5758
5859 const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"});
5960
......@@ -73,8 +74,7 @@ pub fn build(b: *Builder) !void {
7374 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
7475 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
7576 if (!skip_self_hosted) {
76 // TODO re-enable this after https://github.com/ziglang/zig/issues/2377
77 //test_step.dependOn(&exe.step);
77 test_step.dependOn(&exe.step);
7878 }
7979
8080 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 {
9898
9999 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");
100100 test_stage2_step.dependOn(&test_stage2.step);
101
102 // TODO see https://github.com/ziglang/zig/issues/1364
103 if (false) {
104 test_step.dependOn(test_stage2_step);
105 }
101 test_step.dependOn(test_stage2_step);
106102
107103 var chosen_modes: [4]builtin.Mode = undefined;
108104 var chosen_mode_index: usize = 0;
lib/std/event/group.zig+2-3
......@@ -66,11 +66,10 @@ pub fn Group(comptime ReturnType: type) type {
6666 node.* = AllocStack.Node{
6767 .next = undefined,
6868 .data = Node{
69 .handle = frame,
70 .bytes = @sliceToBytes((*[1]@Frame(func))(frame)[0..]),
69 .handle = @asyncCall(frame, {}, func, args),
70 .bytes = std.mem.asBytes(frame),
7171 },
7272 };
73 frame.* = async func(args);
7473 self.alloc_stack.push(node);
7574 }
7675
src-self-hosted/test.zig+12-10
......@@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler;
1010var ctx: TestContext = undefined;
1111
1212test "stage2" {
13 // TODO provide a way to run tests in evented I/O mode
14 if (!std.io.is_async) return error.SkipZigTest;
15
1316 try ctx.init();
1417 defer ctx.deinit();
1518
16 try @import("../test/stage2/compile_errors.zig").addCases(&ctx);
17 try @import("../test/stage2/compare_output.zig").addCases(&ctx);
19 try @import("stage2_tests").addCases(&ctx);
1820
19 async ctx.run();
21 _ = async ctx.run();
2022}
2123
2224const file1 = "1.zig";
......@@ -40,7 +42,7 @@ pub const TestContext = struct {
4042 .file_index = std.atomic.Int(usize).init(0),
4143 };
4244
43 self.zig_compiler = try ZigCompiler.init();
45 self.zig_compiler = try ZigCompiler.init(allocator);
4446 errdefer self.zig_compiler.deinit();
4547
4648 self.group = std.event.Group(anyerror!void).init(allocator);
......@@ -75,7 +77,7 @@ pub const TestContext = struct {
7577 ) !void {
7678 var file_index_buf: [20]u8 = undefined;
7779 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());
78 const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 });
80 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
7981
8082 if (std.fs.path.dirname(file1_path)) |dirname| {
8183 try std.fs.makePath(allocator, dirname);
......@@ -108,9 +110,9 @@ pub const TestContext = struct {
108110 ) !void {
109111 var file_index_buf: [20]u8 = undefined;
110112 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());
111 const file1_path = try std.fs.path.join(allocator, [][]const u8{ tmp_dir_name, file_index, file1 });
113 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
112114
113 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, Target(Target.Native).exeFileExt());
115 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{.Native = {}}).exeFileExt());
114116 if (std.fs.path.dirname(file1_path)) |dirname| {
115117 try std.fs.makePath(allocator, dirname);
116118 }
......@@ -141,7 +143,7 @@ pub const TestContext = struct {
141143 comp: *Compilation,
142144 exe_file: []const u8,
143145 expected_output: []const u8,
144 ) !void {
146 ) anyerror!void {
145147 // TODO this should not be necessary
146148 const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);
147149
......@@ -150,7 +152,7 @@ pub const TestContext = struct {
150152
151153 switch (build_event) {
152154 .Ok => {
153 const argv = []const []const u8{exe_file_2};
155 const argv = [_][]const u8{exe_file_2};
154156 // TODO use event loop
155157 const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
156158 switch (child.term) {
......@@ -186,7 +188,7 @@ pub const TestContext = struct {
186188 line: usize,
187189 column: usize,
188190 text: []const u8,
189 ) !void {
191 ) anyerror!void {
190192 defer comp.destroy();
191193 const build_event = comp.events.get();
192194
test/stage2/test.zig created+6
......@@ -0,0 +1,6 @@
1const TestContext = @import("../../src-self-hosted/test.zig").TestContext;
2
3pub fn addCases(ctx: *TestContext) !void {
4 try @import("compile_errors.zig").addCases(ctx);
5 try @import("compare_output.zig").addCases(ctx);
6}