diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-06-14 15:27:43 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-14 15:27:43 -0700 |
| commit | 8caa20641787944651f7c6fe2f664e93c55d79ec (patch) | |
| tree | 048fa7ebc9c4d30a863ccb18c0d8f40953bd46a0 /src | |
| parent | 22690efcc2378222503cb8aaad26a6f4a539f5aa (diff) | |
| download | zig-8caa20641787944651f7c6fe2f664e93c55d79ec.tar.gz zig-8caa20641787944651f7c6fe2f664e93c55d79ec.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/test.zig b/src/test.zig index f8b8ed8ce8..414a9d4d82 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1808,6 +1808,11 @@ pub const TestContext = struct { // We wouldn't be able to run the compiled C code. return; // Pass test. } + // Use an absolute path here so that the unique directory name + // for this Case makes it into the cache hash, avoiding cache + // collisions from multiple threads doing `zig run` at the same + // time on the same test_case.c input filename. + const abs_exe_path = try tmp.dir.realpathAlloc(arena, bin_name); try argv.appendSlice(&[_][]const u8{ std.testing.zig_exe_path, "run", @@ -1818,7 +1823,7 @@ pub const TestContext = struct { "-Wno-incompatible-library-redeclaration", // https://github.com/ziglang/zig/issues/875 "--", "-lc", - exe_path, + abs_exe_path, }); } else switch (host.getExternalExecutor(target_info, .{ .link_libc = case.link_libc })) { .native => try argv.append(exe_path), |
