diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-13 23:57:15 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-13 23:57:15 -0400 |
| commit | 802f220739c26081e3018fe7e77e199458ffa8ba (patch) | |
| tree | 442689a62f99e8f0dc64e67e090e95d0aa2a0fda /src/test.zig | |
| parent | f32928c50dabde1dee40b7137beef0fe72e89b49 (diff) | |
| parent | 0cd43b0f8686075cf9bb8b8655ca828bd329d60f (diff) | |
| download | zig-802f220739c26081e3018fe7e77e199458ffa8ba.tar.gz zig-802f220739c26081e3018fe7e77e199458ffa8ba.zip | |
Merge pull request #11647 from ziglang/migrate-runtime-safety-tests
migrate runtime safety tests to the new test harness
Diffstat (limited to 'src/test.zig')
| -rw-r--r-- | src/test.zig | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/test.zig b/src/test.zig index c5dda0757f..585c6d62e3 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1201,6 +1201,9 @@ pub const TestContext = struct { if (!build_options.have_llvm and case.backend == .llvm) continue; + if (build_options.test_filter) |test_filter| { + if (std.mem.indexOf(u8, case.name, test_filter) == null) continue; + } var prg_node = root_node.start(case.name, case.updates.items.len); prg_node.activate(); defer prg_node.end(); @@ -1291,6 +1294,8 @@ pub const TestContext = struct { if (case.is_test) { try zig_args.append("test"); + } else if (update.case == .Execution) { + try zig_args.append("run"); } else switch (case.output_mode) { .Obj => try zig_args.append("build-obj"), .Exe => try zig_args.append("build-exe"), @@ -1330,6 +1335,7 @@ pub const TestContext = struct { } }, else => { + std.debug.print("{s}", .{result.stderr}); dumpArgs(zig_args.items); return error.CompilationCrashed; }, @@ -1394,7 +1400,24 @@ pub const TestContext = struct { } }, .CompareObjectFile => @panic("TODO implement in the test harness"), - .Execution => @panic("TODO implement in the test harness"), + .Execution => |expected_stdout| { + switch (result.term) { + .Exited => |code| { + if (code != 0) { + std.debug.print("{s}", .{result.stderr}); + dumpArgs(zig_args.items); + return error.CompilationFailed; + } + }, + else => { + std.debug.print("{s}", .{result.stderr}); + dumpArgs(zig_args.items); + return error.CompilationCrashed; + }, + } + try std.testing.expectEqualStrings("", result.stderr); + try std.testing.expectEqualStrings(expected_stdout, result.stdout); + }, .Header => @panic("TODO implement in the test harness"), } return; |
