| ... | ... | @@ -10,13 +10,15 @@ const ZigCompiler = @import("compilation.zig").ZigCompiler; |
| 10 | 10 | var ctx: TestContext = undefined; |
| 11 | 11 | |
| 12 | 12 | test "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 | 16 | try ctx.init(); |
| 14 | 17 | defer ctx.deinit(); |
| 15 | 18 | |
| 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); |
| 18 | 20 | |
| 19 | | async ctx.run(); |
| 21 | _ = async ctx.run(); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | const file1 = "1.zig"; |
| ... | ... | @@ -40,7 +42,7 @@ pub const TestContext = struct { |
| 40 | 42 | .file_index = std.atomic.Int(usize).init(0), |
| 41 | 43 | }; |
| 42 | 44 | |
| 43 | | self.zig_compiler = try ZigCompiler.init(); |
| 45 | self.zig_compiler = try ZigCompiler.init(allocator); |
| 44 | 46 | errdefer self.zig_compiler.deinit(); |
| 45 | 47 | |
| 46 | 48 | self.group = std.event.Group(anyerror!void).init(allocator); |
| ... | ... | @@ -75,7 +77,7 @@ pub const TestContext = struct { |
| 75 | 77 | ) !void { |
| 76 | 78 | var file_index_buf: [20]u8 = undefined; |
| 77 | 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 }); |
| 79 | 81 | |
| 80 | 82 | if (std.fs.path.dirname(file1_path)) |dirname| { |
| 81 | 83 | try std.fs.makePath(allocator, dirname); |
| ... | ... | @@ -108,9 +110,9 @@ pub const TestContext = struct { |
| 108 | 110 | ) !void { |
| 109 | 111 | var file_index_buf: [20]u8 = undefined; |
| 110 | 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 }); |
| 112 | 114 | |
| 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 | 116 | if (std.fs.path.dirname(file1_path)) |dirname| { |
| 115 | 117 | try std.fs.makePath(allocator, dirname); |
| 116 | 118 | } |
| ... | ... | @@ -141,7 +143,7 @@ pub const TestContext = struct { |
| 141 | 143 | comp: *Compilation, |
| 142 | 144 | exe_file: []const u8, |
| 143 | 145 | expected_output: []const u8, |
| 144 | | ) !void { |
| 146 | ) anyerror!void { |
| 145 | 147 | // TODO this should not be necessary |
| 146 | 148 | const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file); |
| 147 | 149 | |
| ... | ... | @@ -150,7 +152,7 @@ pub const TestContext = struct { |
| 150 | 152 | |
| 151 | 153 | switch (build_event) { |
| 152 | 154 | .Ok => { |
| 153 | | const argv = []const []const u8{exe_file_2}; |
| 155 | const argv = [_][]const u8{exe_file_2}; |
| 154 | 156 | // TODO use event loop |
| 155 | 157 | const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024); |
| 156 | 158 | switch (child.term) { |
| ... | ... | @@ -186,7 +188,7 @@ pub const TestContext = struct { |
| 186 | 188 | line: usize, |
| 187 | 189 | column: usize, |
| 188 | 190 | text: []const u8, |
| 189 | | ) !void { |
| 191 | ) anyerror!void { |
| 190 | 192 | defer comp.destroy(); |
| 191 | 193 | const build_event = comp.events.get(); |
| 192 | 194 | |