@@ -1800,19 +1800,21 @@ pub const TestContext = struct {
1800
1800
exec_node .activate ();
1801
1801
defer exec_node .end ();
1802
1802
1803
- // We use relative to cwd here because we pass a new cwd to the
1804
- // child process.
1805
- const exe_path = try std .fmt .allocPrint (arena , "." ++ std .fs .path .sep_str ++ "{s}" , .{bin_name });
1803
+ // We go out of our way here to use the unique temporary directory name in
1804
+ // the exe_path so that it makes its way into the cache hash, avoiding
1805
+ // cache collisions from multiple threads doing `zig run` at the same time
1806
+ // on the same test_case.c input filename.
1807
+ const ss = std .fs .path .sep_str ;
1808
+ const exe_path = try std .fmt .allocPrint (
1809
+ arena ,
1810
+ ".." ++ ss ++ "{s}" ++ ss ++ "{s}" ,
1811
+ .{ & tmp .sub_path , bin_name },
1812
+ );
1806
1813
if (case .object_format != null and case .object_format .? == .c ) {
1807
1814
if (host .getExternalExecutor (target_info , .{ .link_libc = true }) != .native ) {
1808
1815
// We wouldn't be able to run the compiled C code.
1809
1816
return ; // Pass test.
1810
1817
}
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 );
1816
1818
try argv .appendSlice (&[_ ][]const u8 {
1817
1819
std .testing .zig_exe_path ,
1818
1820
"run" ,
@@ -1823,7 +1825,7 @@ pub const TestContext = struct {
1823
1825
"-Wno-incompatible-library-redeclaration" , // https://github.com/ziglang/zig/issues/875
1824
1826
"--" ,
1825
1827
"-lc" ,
1826
- abs_exe_path ,
1828
+ exe_path ,
1827
1829
});
1828
1830
} else switch (host .getExternalExecutor (target_info , .{ .link_libc = case .link_libc })) {
1829
1831
.native = > try argv .append (exe_path ),
0 commit comments