authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-11 19:44:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-16 13:12:47-07:00
log30c3c666ab88702c5a684ea489a2867260eab22a
tree6602a7868484f89bc68bde170c343c14900e2f6c
parentb91a6dc5b1c99ec8308fd14224d9cd8c44785021

starting to fix the unit test failures


2 files changed, 24 insertions(+), 9 deletions(-)

lib/std/Build/Cache.zig+21-9
......@@ -418,18 +418,18 @@ pub const Manifest = struct {
418418
419419 /// The data per tracked input file that is stored in the manifest file.
420420 pub const File = extern struct {
421 size: u64,
422 inode: u64,
421 size: u64 align(1),
422 inode: u64 align(1),
423423 /// Nanoseconds.
424 mtime: i64,
424 mtime: i64 align(1),
425425 /// To simplify the hashing logic, this value is computed from size, inode, and mtime
426426 /// in `hashFromMetadata` in the case that `Flags.metadata_only` is `true`.
427 digest: BinDigest,
427 digest: BinDigest align(1),
428428 /// Starting with this field and continuing into the path, excluding the null byte,
429429 /// is the string that is hashed for the manifest digest.
430 flags: Flags,
430 flags: Flags align(1),
431431 /// Terminated by zero byte, then followed by padding until 8-byte aligned.
432 path_start: [0]u8,
432 path_start: [0]u8 align(1),
433433
434434 pub const Flags = packed struct(u8) {
435435 is_directory: bool,
......@@ -2133,6 +2133,11 @@ test "cache file and then recall it" {
21332133 const temp_manifest_dir = "temp_manifest_dir";
21342134
21352135 try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = "Hello, world!\n" });
2136 const tmp_directory: Directory = .{
2137 .path = try std.fs.path.join(testing.allocator, &.{std.testing.TmpDir.parent_dir_path}),
2138 .handle = tmp.dir,
2139 };
2140 defer testing.allocator.free(tmp_directory.path.?);
21362141
21372142 // Wait for file timestamps to tick
21382143 const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);
......@@ -2150,7 +2155,8 @@ test "cache file and then recall it" {
21502155 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
21512156 .cwd = cwd,
21522157 };
2153 cache.addPrefix(.{ .path = null, .handle = tmp.dir });
2158 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
2159 cache.addPrefix(tmp_directory);
21542160 defer cache.manifest_dir.close(io);
21552161
21562162 {
......@@ -2160,7 +2166,10 @@ test "cache file and then recall it" {
21602166 ch.hash.add(true);
21612167 ch.hash.add(@as(u16, 1234));
21622168 ch.hash.addBytes("1234");
2163 _ = try ch.addInputPath(.initCwd(temp_file), .{});
2169 _ = try ch.addInputPath(.{
2170 .root_dir = tmp_directory,
2171 .sub_path = temp_file,
2172 }, .{});
21642173
21652174 try testing.expectEqual(.incomplete_manifest, try ch.check(.none));
21662175
......@@ -2174,7 +2183,10 @@ test "cache file and then recall it" {
21742183 ch.hash.add(true);
21752184 ch.hash.add(@as(u16, 1234));
21762185 ch.hash.addBytes("1234");
2177 _ = try ch.addInputPath(.initCwd(temp_file), .{});
2186 _ = try ch.addInputPath(.{
2187 .root_dir = tmp_directory,
2188 .sub_path = temp_file,
2189 }, .{});
21782190
21792191 // Cache hit! We just "built" the same file
21802192 try testing.expectEqual(.hit, try ch.check(.none));
lib/std/testing.zig+3
......@@ -592,6 +592,9 @@ pub const TmpDir = struct {
592592 const random_bytes_count = 12;
593593 const sub_path_len = std.base64.url_safe.Encoder.calcSize(random_bytes_count);
594594
595 /// Deprecated.
596 pub const parent_dir_path: []const u8 = ".zig-cache" ++ std.fs.path.sep_str ++ "tmp";
597
595598 pub fn cleanup(self: *TmpDir) void {
596599 self.dir.close(io);
597600 self.parent_dir.deleteTree(io, &self.sub_path) catch {};