| ... | ... | @@ -418,18 +418,18 @@ pub const Manifest = struct { |
| 418 | 418 | |
| 419 | 419 | /// The data per tracked input file that is stored in the manifest file. |
| 420 | 420 | pub const File = extern struct { |
| 421 | | size: u64, |
| 422 | | inode: u64, |
| 421 | size: u64 align(1), |
| 422 | inode: u64 align(1), |
| 423 | 423 | /// Nanoseconds. |
| 424 | | mtime: i64, |
| 424 | mtime: i64 align(1), |
| 425 | 425 | /// To simplify the hashing logic, this value is computed from size, inode, and mtime |
| 426 | 426 | /// in `hashFromMetadata` in the case that `Flags.metadata_only` is `true`. |
| 427 | | digest: BinDigest, |
| 427 | digest: BinDigest align(1), |
| 428 | 428 | /// Starting with this field and continuing into the path, excluding the null byte, |
| 429 | 429 | /// is the string that is hashed for the manifest digest. |
| 430 | | flags: Flags, |
| 430 | flags: Flags align(1), |
| 431 | 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), |
| 433 | 433 | |
| 434 | 434 | pub const Flags = packed struct(u8) { |
| 435 | 435 | is_directory: bool, |
| ... | ... | @@ -2133,6 +2133,11 @@ test "cache file and then recall it" { |
| 2133 | 2133 | const temp_manifest_dir = "temp_manifest_dir"; |
| 2134 | 2134 | |
| 2135 | 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.?); |
| 2136 | 2141 | |
| 2137 | 2142 | // Wait for file timestamps to tick |
| 2138 | 2143 | const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir); |
| ... | ... | @@ -2150,7 +2155,8 @@ test "cache file and then recall it" { |
| 2150 | 2155 | .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}), |
| 2151 | 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 | 2160 | defer cache.manifest_dir.close(io); |
| 2155 | 2161 | |
| 2156 | 2162 | { |
| ... | ... | @@ -2160,7 +2166,10 @@ test "cache file and then recall it" { |
| 2160 | 2166 | ch.hash.add(true); |
| 2161 | 2167 | ch.hash.add(@as(u16, 1234)); |
| 2162 | 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 | }, .{}); |
| 2164 | 2173 | |
| 2165 | 2174 | try testing.expectEqual(.incomplete_manifest, try ch.check(.none)); |
| 2166 | 2175 | |
| ... | ... | @@ -2174,7 +2183,10 @@ test "cache file and then recall it" { |
| 2174 | 2183 | ch.hash.add(true); |
| 2175 | 2184 | ch.hash.add(@as(u16, 1234)); |
| 2176 | 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 | }, .{}); |
| 2178 | 2190 | |
| 2179 | 2191 | // Cache hit! We just "built" the same file |
| 2180 | 2192 | try testing.expectEqual(.hit, try ch.check(.none)); |