| author | |
| committer | |
| log | 5c8b92db7f6e99d075af1cf87d48a5af0c748603 |
| tree | 6ce024041d0806fac93d26ad8b58fcde85c6877f |
| parent | dd75e7bcb1fe142f4d60dc2d83e6feee53e580f3 |
| signature |
File arguments added to `std.Build.Step.Run` with e.g. `addFileArg` are
not necessarily passed as absolute paths. It used to be the case that
they were as a consequence of an unnecessary path conversion done by the
frontend, but this no longer happens, at least not always, so these
tests were sometimes failing when run locally. Therefore, the standalone
tests must handle cwd-relative CLI paths correctly.5 files changed, 7 insertions(+), 19 deletions(-)
test/standalone/dirname/exists_in.zig+1-6| ... | ... | @@ -29,17 +29,12 @@ fn run(allocator: std.mem.Allocator) !void { |
| 29 | 29 | return error.BadUsage; |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | if (!std.fs.path.isAbsolute(dir_path)) { | |
| 33 | std.log.err("expected <dir> to be an absolute path", .{}); | |
| 34 | return error.BadUsage; | |
| 35 | } | |
| 36 | ||
| 37 | 32 | const relpath = args.next() orelse { |
| 38 | 33 | std.log.err("missing <path> argument", .{}); |
| 39 | 34 | return error.BadUsage; |
| 40 | 35 | }; |
| 41 | 36 | |
| 42 | var dir = try std.fs.openDirAbsolute(dir_path, .{}); | |
| 37 | var dir = try std.fs.cwd().openDir(dir_path, .{}); | |
| 43 | 38 | defer dir.close(); |
| 44 | 39 | |
| 45 | 40 | _ = try dir.statFile(relpath); |
test/standalone/dirname/has_basename.zig-5| ... | ... | @@ -31,11 +31,6 @@ fn run(allocator: std.mem.Allocator) !void { |
| 31 | 31 | return error.BadUsage; |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | if (!std.fs.path.isAbsolute(path)) { | |
| 35 | std.log.err("path must be absolute", .{}); | |
| 36 | return error.BadUsage; | |
| 37 | } | |
| 38 | ||
| 39 | 34 | const basename = args.next() orelse { |
| 40 | 35 | std.log.err("missing <basename> argument", .{}); |
| 41 | 36 | return error.BadUsage; |
test/standalone/dirname/touch.zig+1-6| ... | ... | @@ -26,15 +26,10 @@ fn run(allocator: std.mem.Allocator) !void { |
| 26 | 26 | return error.BadUsage; |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | if (!std.fs.path.isAbsolute(path)) { | |
| 30 | std.log.err("path must be absolute: {s}", .{path}); | |
| 31 | return error.BadUsage; | |
| 32 | } | |
| 33 | ||
| 34 | 29 | const dir_path = std.fs.path.dirname(path) orelse unreachable; |
| 35 | 30 | const basename = std.fs.path.basename(path); |
| 36 | 31 | |
| 37 | var dir = try std.fs.openDirAbsolute(dir_path, .{}); | |
| 32 | var dir = try std.fs.cwd().openDir(dir_path, .{}); | |
| 38 | 33 | defer dir.close(); |
| 39 | 34 | |
| 40 | 35 | _ = dir.statFile(basename) catch { |
test/standalone/run_output_caching/main.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ pub fn main() !void { |
| 4 | 4 | var args = try std.process.argsWithAllocator(std.heap.page_allocator); |
| 5 | 5 | _ = args.skip(); |
| 6 | 6 | const filename = args.next().?; |
| 7 | const file = try std.fs.createFileAbsolute(filename, .{}); | |
| 7 | const file = try std.fs.cwd().createFile(filename, .{}); | |
| 8 | 8 | defer file.close(); |
| 9 | 9 | try file.writeAll(filename); |
| 10 | 10 | } |
test/standalone/self_exe_symlink/create-symlink.zig+4-1| ... | ... | @@ -11,5 +11,8 @@ pub fn main() anyerror!void { |
| 11 | 11 | const exe_path = it.next() orelse unreachable; |
| 12 | 12 | const symlink_path = it.next() orelse unreachable; |
| 13 | 13 | |
| 14 | try std.fs.cwd().symLink(exe_path, symlink_path, .{}); | |
| 14 | // If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`. | |
| 15 | const exe_rel_path = try std.fs.path.relative(allocator, std.fs.path.dirname(symlink_path) orelse ".", exe_path); | |
| 16 | defer allocator.free(exe_rel_path); | |
| 17 | try std.fs.cwd().symLink(exe_rel_path, symlink_path, .{}); | |
| 15 | 18 | } |