use of com.google.devtools.build.lib.vfs.FileSystem.HashFunction in project bazel by bazelbuild.
the class FileFunctionTest method testEmptyFile.
@Test
public void testEmptyFile() throws Exception {
final byte[] digest = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
createFsAndRoot(new CustomInMemoryFs(manualClock) {
@Override
protected byte[] getFastDigest(Path path, HashFunction hf) throws IOException {
return digest;
}
});
Path p = file("file");
p.setLastModifiedTime(0L);
FileValue a = valueForPath(p);
p.setLastModifiedTime(1L);
assertThat(valueForPath(p)).isNotEqualTo(a);
p.setLastModifiedTime(0L);
assertEquals(a, valueForPath(p));
FileSystemUtils.writeContentAsLatin1(p, "content");
// Same digest, but now non-empty.
assertThat(valueForPath(p)).isNotEqualTo(a);
}
Aggregations