authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-14 22:15:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-14 22:15:22-07:00
log0e9458a3fc18bb6e31dda23811943ac3988fa385
tree65c09c6987149544c77f12d58c3dc4f5f566c6f2
parent8caa20641787944651f7c6fe2f664e93c55d79ec

test-cases: avoid using realpath since it is not portable

For example FreeBSD does not support this syscall.

1 files changed, 11 insertions(+), 9 deletions(-)

src/test.zig+11-9
......@@ -1800,19 +1800,21 @@ pub const TestContext = struct {
18001800 exec_node.activate();
18011801 defer exec_node.end();
18021802
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 );
18061813 if (case.object_format != null and case.object_format.? == .c) {
18071814 if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) {
18081815 // We wouldn't be able to run the compiled C code.
18091816 return; // Pass test.
18101817 }
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);
18161818 try argv.appendSlice(&[_][]const u8{
18171819 std.testing.zig_exe_path,
18181820 "run",
......@@ -1823,7 +1825,7 @@ pub const TestContext = struct {
18231825 "-Wno-incompatible-library-redeclaration", // https://github.com/ziglang/zig/issues/875
18241826 "--",
18251827 "-lc",
1826 abs_exe_path,
1828 exe_path,
18271829 });
18281830 } else switch (host.getExternalExecutor(target_info, .{ .link_libc = case.link_libc })) {
18291831 .native => try argv.append(exe_path),