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 {...@@ -418,18 +418,18 @@ pub const Manifest = struct {
418418
419 /// The data per tracked input file that is stored in the manifest file.419 /// The data per tracked input file that is stored in the manifest file.
420 pub const File = extern struct {420 pub const File = extern struct {
421 size: u64,421 size: u64 align(1),
422 inode: u64,422 inode: u64 align(1),
423 /// Nanoseconds.423 /// Nanoseconds.
424 mtime: i64,424 mtime: i64 align(1),
425 /// To simplify the hashing logic, this value is computed from size, inode, and mtime425 /// To simplify the hashing logic, this value is computed from size, inode, and mtime
426 /// in `hashFromMetadata` in the case that `Flags.metadata_only` is `true`.426 /// in `hashFromMetadata` in the case that `Flags.metadata_only` is `true`.
427 digest: BinDigest,427 digest: BinDigest align(1),
428 /// Starting with this field and continuing into the path, excluding the null byte,428 /// Starting with this field and continuing into the path, excluding the null byte,
429 /// is the string that is hashed for the manifest digest.429 /// is the string that is hashed for the manifest digest.
430 flags: Flags,430 flags: Flags align(1),
431 /// Terminated by zero byte, then followed by padding until 8-byte aligned.431 /// 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
434 pub const Flags = packed struct(u8) {434 pub const Flags = packed struct(u8) {
435 is_directory: bool,435 is_directory: bool,
...@@ -2133,6 +2133,11 @@ test "cache file and then recall it" {...@@ -2133,6 +2133,11 @@ test "cache file and then recall it" {
2133 const temp_manifest_dir = "temp_manifest_dir";2133 const temp_manifest_dir = "temp_manifest_dir";
21342134
2135 try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = "Hello, world!\n" });2135 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
2137 // Wait for file timestamps to tick2142 // Wait for file timestamps to tick
2138 const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);2143 const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);
...@@ -2150,7 +2155,8 @@ test "cache file and then recall it" {...@@ -2150,7 +2155,8 @@ test "cache file and then recall it" {
2150 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),2155 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
2151 .cwd = cwd,2156 .cwd = cwd,
2152 };2157 };
2153 cache.addPrefix(.{ .path = null, .handle = tmp.dir });2158 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
2159 cache.addPrefix(tmp_directory);
2154 defer cache.manifest_dir.close(io);2160 defer cache.manifest_dir.close(io);
21552161
2156 {2162 {
...@@ -2160,7 +2166,10 @@ test "cache file and then recall it" {...@@ -2160,7 +2166,10 @@ test "cache file and then recall it" {
2160 ch.hash.add(true);2166 ch.hash.add(true);
2161 ch.hash.add(@as(u16, 1234));2167 ch.hash.add(@as(u16, 1234));
2162 ch.hash.addBytes("1234");2168 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
2165 try testing.expectEqual(.incomplete_manifest, try ch.check(.none));2174 try testing.expectEqual(.incomplete_manifest, try ch.check(.none));
21662175
...@@ -2174,7 +2183,10 @@ test "cache file and then recall it" {...@@ -2174,7 +2183,10 @@ test "cache file and then recall it" {
2174 ch.hash.add(true);2183 ch.hash.add(true);
2175 ch.hash.add(@as(u16, 1234));2184 ch.hash.add(@as(u16, 1234));
2176 ch.hash.addBytes("1234");2185 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
2179 // Cache hit! We just "built" the same file2191 // Cache hit! We just "built" the same file
2180 try testing.expectEqual(.hit, try ch.check(.none));2192 try testing.expectEqual(.hit, try ch.check(.none));
lib/std/testing.zig+3
...@@ -592,6 +592,9 @@ pub const TmpDir = struct {...@@ -592,6 +592,9 @@ pub const TmpDir = struct {
592 const random_bytes_count = 12;592 const random_bytes_count = 12;
593 const sub_path_len = std.base64.url_safe.Encoder.calcSize(random_bytes_count);593 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
595 pub fn cleanup(self: *TmpDir) void {598 pub fn cleanup(self: *TmpDir) void {
596 self.dir.close(io);599 self.dir.close(io);
597 self.parent_dir.deleteTree(io, &self.sub_path) catch {};600 self.parent_dir.deleteTree(io, &self.sub_path) catch {};