authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-14 15:27:43-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-14 15:27:43-07:00
log8caa20641787944651f7c6fe2f664e93c55d79ec
tree048fa7ebc9c4d30a863ccb18c0d8f40953bd46a0
parent22690efcc2378222503cb8aaad26a6f4a539f5aa

test-cases: fix race with `zig run` on C backend tests

Also avoid redundantly doing compile-error checks on multiple targets for test cases where that is not helpful.

6 files changed, 15 insertions(+), 4 deletions(-)

src/test.zig+6-1
...@@ -1808,6 +1808,11 @@ pub const TestContext = struct {...@@ -1808,6 +1808,11 @@ pub const TestContext = struct {
1808 // We wouldn't be able to run the compiled C code.1808 // We wouldn't be able to run the compiled C code.
1809 return; // Pass test.1809 return; // Pass test.
1810 }1810 }
1811 // Use an absolute path here so that the unique directory name
1812 // for this Case makes it into the cache hash, avoiding cache
1813 // collisions from multiple threads doing `zig run` at the same
1814 // time on the same test_case.c input filename.
1815 const abs_exe_path = try tmp.dir.realpathAlloc(arena, bin_name);
1811 try argv.appendSlice(&[_][]const u8{1816 try argv.appendSlice(&[_][]const u8{
1812 std.testing.zig_exe_path,1817 std.testing.zig_exe_path,
1813 "run",1818 "run",
...@@ -1818,7 +1823,7 @@ pub const TestContext = struct {...@@ -1818,7 +1823,7 @@ pub const TestContext = struct {
1818 "-Wno-incompatible-library-redeclaration", // https://github.com/ziglang/zig/issues/8751823 "-Wno-incompatible-library-redeclaration", // https://github.com/ziglang/zig/issues/875
1819 "--",1824 "--",
1820 "-lc",1825 "-lc",
1821 exe_path,1826 abs_exe_path,
1822 });1827 });
1823 } else switch (host.getExternalExecutor(target_info, .{ .link_libc = case.link_libc })) {1828 } else switch (host.getExternalExecutor(target_info, .{ .link_libc = case.link_libc })) {
1824 .native => try argv.append(exe_path),1829 .native => try argv.append(exe_path),
test/cases/compile_errors/dereference_anyopaque.zig+1
...@@ -41,6 +41,7 @@ pub export fn entry() void {...@@ -41,6 +41,7 @@ pub export fn entry() void {
41}41}
4242
43// error43// error
44// target=native
44// backend=llvm45// backend=llvm
45//46//
46// :11:22: error: comparison of 'void' with null47// :11:22: error: comparison of 'void' with null
test/cases/compile_errors/invalid_array_elem_ty.zig+2-1
...@@ -6,6 +6,7 @@ pub export fn entry() void {...@@ -6,6 +6,7 @@ pub export fn entry() void {
6}6}
77
8// error8// error
9// backend=stage2,llvm9// target=native
10// backend=stage2
10//11//
11// :4:1: error: expected type, found fn() type12// :4:1: error: expected type, found fn() type
test/cases/compile_errors/invalid_store_to_comptime_field.zig+2-1
...@@ -14,7 +14,8 @@ pub export fn entry1() void {...@@ -14,7 +14,8 @@ pub export fn entry1() void {
14 s.a = T{ .a = 2, .b = 2 };14 s.a = T{ .a = 2, .b = 2 };
15}15}
16// error16// error
17// backend=stage2,llvm17// target=native
18// backend=stage2
18//19//
19// :6:19: error: value stored in comptime field does not match the default value of the field20// :6:19: error: value stored in comptime field does not match the default value of the field
20// :14:19: error: value stored in comptime field does not match the default value of the field21// :14:19: error: value stored in comptime field does not match the default value of the field
test/cases/compile_errors/runtime_indexing_comptime_array.zig+2-1
...@@ -21,7 +21,8 @@ pub export fn entry3() void {...@@ -21,7 +21,8 @@ pub export fn entry3() void {
21 _ = &test_fns[i];21 _ = &test_fns[i];
22}22}
23// error23// error
24// backend=stage2,llvm24// target=native
25// backend=stage2
25//26//
26// :6:5: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known27// :6:5: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known
27// :6:5: note: use '*const fn() void' for a function pointer type28// :6:5: note: use '*const fn() void' for a function pointer type
test/cases/compile_errors/stage2/comptime_unreachable.zig+2
...@@ -3,5 +3,7 @@ pub export fn entry() void {...@@ -3,5 +3,7 @@ pub export fn entry() void {
3}3}
44
5// error5// error
6// target=native
7// backend=stage2
6//8//
7// :2:14: error: reached unreachable code9// :2:14: error: reached unreachable code