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 {...@@ -54,6 +54,7 @@ pub fn build(b: *Builder) !void {
5454
55 var test_stage2 = b.addTest("src-self-hosted/test.zig");55 var test_stage2 = b.addTest("src-self-hosted/test.zig");
56 test_stage2.setBuildMode(builtin.Mode.Debug);56 test_stage2.setBuildMode(builtin.Mode.Debug);
57 test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig");
5758
58 const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"});59 const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"});
5960
...@@ -73,8 +74,7 @@ pub fn build(b: *Builder) !void {...@@ -73,8 +74,7 @@ pub fn build(b: *Builder) !void {
73 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;74 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
74 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;75 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
75 if (!skip_self_hosted) {76 if (!skip_self_hosted) {
76 // TODO re-enable this after https://github.com/ziglang/zig/issues/237777 test_step.dependOn(&exe.step);
77 //test_step.dependOn(&exe.step);
78 }78 }
7979
80 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;80 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 {...@@ -98,11 +98,7 @@ pub fn build(b: *Builder) !void {
9898
99 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");99 const test_stage2_step = b.step("test-stage2", "Run the stage2 compiler tests");
100 test_stage2_step.dependOn(&test_stage2.step);100 test_stage2_step.dependOn(&test_stage2.step);
101101 test_step.dependOn(test_stage2_step);
102 // TODO see https://github.com/ziglang/zig/issues/1364
103 if (false) {
104 test_step.dependOn(test_stage2_step);
105 }
106102
107 var chosen_modes: [4]builtin.Mode = undefined;103 var chosen_modes: [4]builtin.Mode = undefined;
108 var chosen_mode_index: usize = 0;104 var chosen_mode_index: usize = 0;
lib/std/event/group.zig+2-3
...@@ -66,11 +66,10 @@ pub fn Group(comptime ReturnType: type) type {...@@ -66,11 +66,10 @@ pub fn Group(comptime ReturnType: type) type {
66 node.* = AllocStack.Node{66 node.* = AllocStack.Node{
67 .next = undefined,67 .next = undefined,
68 .data = Node{68 .data = Node{
69 .handle = frame,69 .handle = @asyncCall(frame, {}, func, args),
70 .bytes = @sliceToBytes((*[1]@Frame(func))(frame)[0..]),70 .bytes = std.mem.asBytes(frame),
71 },71 },
72 };72 };
73 frame.* = async func(args);
74 self.alloc_stack.push(node);73 self.alloc_stack.push(node);
75 }74 }
7675
src-self-hosted/test.zig+12-10
...@@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler;...@@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler;
10var ctx: TestContext = undefined;10var ctx: TestContext = undefined;
1111
12test "stage2" {12test "stage2" {
13 // TODO provide a way to run tests in evented I/O mode
14 if (!std.io.is_async) return error.SkipZigTest;
15
13 try ctx.init();16 try ctx.init();
14 defer ctx.deinit();17 defer ctx.deinit();
1518
16 try @import("../test/stage2/compile_errors.zig").addCases(&ctx);19 try @import("stage2_tests").addCases(&ctx);
17 try @import("../test/stage2/compare_output.zig").addCases(&ctx);
1820
19 async ctx.run();21 _ = async ctx.run();
20}22}
2123
22const file1 = "1.zig";24const file1 = "1.zig";
...@@ -40,7 +42,7 @@ pub const TestContext = struct {...@@ -40,7 +42,7 @@ pub const TestContext = struct {
40 .file_index = std.atomic.Int(usize).init(0),42 .file_index = std.atomic.Int(usize).init(0),
41 };43 };
4244
43 self.zig_compiler = try ZigCompiler.init();45 self.zig_compiler = try ZigCompiler.init(allocator);
44 errdefer self.zig_compiler.deinit();46 errdefer self.zig_compiler.deinit();
4547
46 self.group = std.event.Group(anyerror!void).init(allocator);48 self.group = std.event.Group(anyerror!void).init(allocator);
...@@ -75,7 +77,7 @@ pub const TestContext = struct {...@@ -75,7 +77,7 @@ pub const TestContext = struct {
75 ) !void {77 ) !void {
76 var file_index_buf: [20]u8 = undefined;78 var file_index_buf: [20]u8 = undefined;
77 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());79 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
80 if (std.fs.path.dirname(file1_path)) |dirname| {82 if (std.fs.path.dirname(file1_path)) |dirname| {
81 try std.fs.makePath(allocator, dirname);83 try std.fs.makePath(allocator, dirname);
...@@ -108,9 +110,9 @@ pub const TestContext = struct {...@@ -108,9 +110,9 @@ pub const TestContext = struct {
108 ) !void {110 ) !void {
109 var file_index_buf: [20]u8 = undefined;111 var file_index_buf: [20]u8 = undefined;
110 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());112 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());
114 if (std.fs.path.dirname(file1_path)) |dirname| {116 if (std.fs.path.dirname(file1_path)) |dirname| {
115 try std.fs.makePath(allocator, dirname);117 try std.fs.makePath(allocator, dirname);
116 }118 }
...@@ -141,7 +143,7 @@ pub const TestContext = struct {...@@ -141,7 +143,7 @@ pub const TestContext = struct {
141 comp: *Compilation,143 comp: *Compilation,
142 exe_file: []const u8,144 exe_file: []const u8,
143 expected_output: []const u8,145 expected_output: []const u8,
144 ) !void {146 ) anyerror!void {
145 // TODO this should not be necessary147 // TODO this should not be necessary
146 const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);148 const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);
147149
...@@ -150,7 +152,7 @@ pub const TestContext = struct {...@@ -150,7 +152,7 @@ pub const TestContext = struct {
150152
151 switch (build_event) {153 switch (build_event) {
152 .Ok => {154 .Ok => {
153 const argv = []const []const u8{exe_file_2};155 const argv = [_][]const u8{exe_file_2};
154 // TODO use event loop156 // TODO use event loop
155 const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);157 const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
156 switch (child.term) {158 switch (child.term) {
...@@ -186,7 +188,7 @@ pub const TestContext = struct {...@@ -186,7 +188,7 @@ pub const TestContext = struct {
186 line: usize,188 line: usize,
187 column: usize,189 column: usize,
188 text: []const u8,190 text: []const u8,
189 ) !void {191 ) anyerror!void {
190 defer comp.destroy();192 defer comp.destroy();
191 const build_event = comp.events.get();193 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}