aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted/test.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-11-27 13:38:49 -0500
committerGitHub <noreply@github.com>2019-11-27 13:38:49 -0500
commit83c664eaa080669cff83f7c30046376f3399eafb (patch)
tree06cccc09052be4459e924d04a867ff34a889d87c /src-self-hosted/test.zig
parent63300a21ddf4cfe209a39796c6d7ea7773e14fd6 (diff)
parent4d8a8e65df79ddd5edf52f961552036ccfca6e8e (diff)
downloadzig-83c664eaa080669cff83f7c30046376f3399eafb.tar.gz
zig-83c664eaa080669cff83f7c30046376f3399eafb.zip
Merge pull request #3780 from Vexu/stage2-async-review
Update use of async functions in self hosted compiler
Diffstat (limited to 'src-self-hosted/test.zig')
-rw-r--r--src-self-hosted/test.zig24
1 files changed, 11 insertions, 13 deletions
diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig
index 85b9d6b912..62b7914dbc 100644
--- a/src-self-hosted/test.zig
+++ b/src-self-hosted/test.zig
@@ -26,7 +26,8 @@ test "stage2" {
}
const file1 = "1.zig";
-const allocator = std.heap.c_allocator;
+// TODO https://github.com/ziglang/zig/issues/3783
+const allocator = std.heap.page_allocator;
pub const TestContext = struct {
zig_compiler: ZigCompiler,
@@ -94,8 +95,8 @@ pub const TestContext = struct {
&self.zig_compiler,
"test",
file1_path,
- Target.Native,
- Compilation.Kind.Obj,
+ .Native,
+ .Obj,
.Debug,
true, // is_static
self.zig_lib_dir,
@@ -116,7 +117,7 @@ pub const TestContext = struct {
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 output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (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);
}
@@ -128,8 +129,8 @@ pub const TestContext = struct {
&self.zig_compiler,
"test",
file1_path,
- Target.Native,
- Compilation.Kind.Exe,
+ .Native,
+ .Exe,
.Debug,
false,
self.zig_lib_dir,
@@ -148,15 +149,12 @@ pub const TestContext = struct {
exe_file: []const u8,
expected_output: []const u8,
) anyerror!void {
- // TODO this should not be necessary
- const exe_file_2 = try std.mem.dupe(allocator, u8, exe_file);
-
defer comp.destroy();
const build_event = comp.events.get();
switch (build_event) {
.Ok => {
- const argv = [_][]const u8{exe_file_2};
+ const argv = [_][]const u8{exe_file};
// TODO use event loop
const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
switch (child.term) {
@@ -173,13 +171,13 @@ pub const TestContext = struct {
return error.OutputMismatch;
}
},
- Compilation.Event.Error => |err| return err,
- Compilation.Event.Fail => |msgs| {
+ .Error => @panic("Cannot return error: https://github.com/ziglang/zig/issues/3190"), // |err| return err,
+ .Fail => |msgs| {
const stderr = std.io.getStdErr();
try stderr.write("build incorrectly failed:\n");
for (msgs) |msg| {
defer msg.destroy();
- try msg.printToFile(stderr, errmsg.Color.Auto);
+ try msg.printToFile(stderr, .Auto);
}
},
}