| ... | ... | @@ -561,10 +561,10 @@ pub const TestContext = struct { |
| 561 | 561 | |
| 562 | 562 | var cache_dir = try tmp.dir.makeOpenPath("zig-cache", .{}); |
| 563 | 563 | defer cache_dir.close(); |
| 564 | | const tmp_path = try std.fs.path.join(arena, &[_][]const u8{ ".", "zig-cache", "tmp", &tmp.sub_path }); |
| 564 | const tmp_dir_path = try std.fs.path.join(arena, &[_][]const u8{ ".", "zig-cache", "tmp", &tmp.sub_path }); |
| 565 | 565 | const zig_cache_directory: Compilation.Directory = .{ |
| 566 | 566 | .handle = cache_dir, |
| 567 | | .path = try std.fs.path.join(arena, &[_][]const u8{ tmp_path, "zig-cache" }), |
| 567 | .path = try std.fs.path.join(arena, &[_][]const u8{ tmp_dir_path, "zig-cache" }), |
| 568 | 568 | }; |
| 569 | 569 | |
| 570 | 570 | const tmp_src_path = switch (case.extension) { |
| ... | ... | @@ -573,7 +573,7 @@ pub const TestContext = struct { |
| 573 | 573 | }; |
| 574 | 574 | |
| 575 | 575 | var root_pkg: Package = .{ |
| 576 | | .root_src_directory = .{ .path = tmp_path, .handle = tmp.dir }, |
| 576 | .root_src_directory = .{ .path = tmp_dir_path, .handle = tmp.dir }, |
| 577 | 577 | .root_src_path = tmp_src_path, |
| 578 | 578 | }; |
| 579 | 579 | |
| ... | ... | @@ -585,7 +585,7 @@ pub const TestContext = struct { |
| 585 | 585 | }); |
| 586 | 586 | |
| 587 | 587 | const emit_directory: Compilation.Directory = .{ |
| 588 | | .path = tmp_path, |
| 588 | .path = tmp_dir_path, |
| 589 | 589 | .handle = tmp.dir, |
| 590 | 590 | }; |
| 591 | 591 | const emit_bin: Compilation.EmitLoc = .{ |
| ... | ... | @@ -771,7 +771,9 @@ pub const TestContext = struct { |
| 771 | 771 | exec_node.activate(); |
| 772 | 772 | defer exec_node.end(); |
| 773 | 773 | |
| 774 | | const exe_path = try emit_directory.join(arena, &[_][]const u8{bin_name}); |
| 774 | // We use relative to cwd here because we pass a new cwd to the |
| 775 | // child process. |
| 776 | const exe_path = try std.fmt.allocPrint(arena, "." ++ std.fs.path.sep_str ++ "{s}", .{bin_name}); |
| 775 | 777 | if (case.object_format != null and case.object_format.? == .c) { |
| 776 | 778 | try argv.appendSlice(&[_][]const u8{ |
| 777 | 779 | std.testing.zig_exe_path, "run", exe_path, "-lc", |
| ... | ... | @@ -824,11 +826,18 @@ pub const TestContext = struct { |
| 824 | 826 | |
| 825 | 827 | try comp.makeBinFileExecutable(); |
| 826 | 828 | |
| 827 | | break :x try std.ChildProcess.exec(.{ |
| 829 | break :x std.ChildProcess.exec(.{ |
| 828 | 830 | .allocator = allocator, |
| 829 | 831 | .argv = argv.items, |
| 830 | 832 | .cwd_dir = tmp.dir, |
| 831 | | }); |
| 833 | .cwd = tmp_dir_path, |
| 834 | }) catch |err| { |
| 835 | std.debug.print("\nThe following command failed with {s}:\n", .{ |
| 836 | @errorName(err), |
| 837 | }); |
| 838 | dumpArgs(argv.items); |
| 839 | return error.ZigTestFailed; |
| 840 | }; |
| 832 | 841 | }; |
| 833 | 842 | var test_node = update_node.start("test", 0); |
| 834 | 843 | test_node.activate(); |
| ... | ... | @@ -976,4 +985,4 @@ fn dumpArgs(argv: []const []const u8) void { |
| 976 | 985 | std.debug.print("{s} ", .{arg}); |
| 977 | 986 | } |
| 978 | 987 | std.debug.print("\n", .{}); |
| 979 | | } |
| | \ No newline at end of file |
| 988 | } |