Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+scratch-dir.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`zig build test` passes when the directory it runs in has no `.zig-cache`, as when `ZIG_LOCAL_CACHE_DIR` puts the cache elsewhere: the unit test of a failed copy makes its scratch directory with its parents instead of failing with `NotFound`.
11 changes: 5 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,12 @@ test "a failed copy does not replace a log already kept" {
const here = try fsx.realpath(fsx.cwd, ".", &cwd_buf);
const base = try std.fmt.allocPrint(gpa, "{s}/.zig-cache/eb-keep-logs-copy-{d}", .{ here, linux.getpid() });
defer gpa.free(base);
var zb: [sys.path_max:0]u8 = undefined;
_ = linux.mkdirat(fsx.cwd, (try sys.z(&zb, base)).ptr, 0o700);
// The test runs where `zig build` was started, which has no .zig-cache
// when the cache is elsewhere, as with ZIG_LOCAL_CACHE_DIR.
try common.atomic.makedirs(base);
defer fsx.deleteTree(gpa, fsx.cwd, base) catch {};
const dir = try fsx.openDir(fsx.cwd, base, false);
defer {
fsx.deleteTree(gpa, fsx.cwd, base) catch {};
sys.close(dir);
}
defer sys.close(dir);
const dst = try sys.openat(dir, "kept.log", .{ .ACCMODE = .WRONLY, .CREAT = true }, 0o640);
try sys.writeAll(dst, "OLDDATA\n");
sys.close(dst);
Expand Down
Loading