use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class FileFunctionTest method testFileStateEquality.
@Test
public void testFileStateEquality() throws Exception {
file("a");
symlink("b1", "a");
symlink("b2", "a");
symlink("b3", "zzz");
directory("d1");
directory("d2");
SkyKey file = fileStateSkyKey("a");
SkyKey symlink1 = fileStateSkyKey("b1");
SkyKey symlink2 = fileStateSkyKey("b2");
SkyKey symlink3 = fileStateSkyKey("b3");
SkyKey missing1 = fileStateSkyKey("c1");
SkyKey missing2 = fileStateSkyKey("c2");
SkyKey directory1 = fileStateSkyKey("d1");
SkyKey directory2 = fileStateSkyKey("d2");
ImmutableList<SkyKey> keys = ImmutableList.of(file, symlink1, symlink2, symlink3, missing1, missing2, directory1, directory2);
SequentialBuildDriver driver = makeDriver();
EvaluationResult<SkyValue> result = driver.evaluate(keys, false, DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
new EqualsTester().addEqualityGroup(result.get(file)).addEqualityGroup(result.get(symlink1), result.get(symlink2)).addEqualityGroup(result.get(symlink3)).addEqualityGroup(result.get(missing1), result.get(missing2)).addEqualityGroup(result.get(directory1), result.get(directory2)).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class ArtifactFunctionTest method testEquality.
@Test
public void testEquality() throws Exception {
Artifact artifact1 = createDerivedArtifact("artifact1");
Artifact artifact2 = createDerivedArtifact("artifact2");
Artifact diffDigest = createDerivedArtifact("diffDigest");
Artifact diffMtime = createDerivedArtifact("diffMtime");
Artifact empty1 = createDerivedArtifact("empty1");
Artifact empty2 = createDerivedArtifact("empty2");
Artifact empty3 = createDerivedArtifact("empty3");
Artifact dir1 = createDerivedArtifact("dir1");
Artifact dir2 = createDerivedArtifact("dir2");
Artifact dir3 = createDerivedArtifact("dir3");
Path path1 = artifact1.getPath();
Path path2 = artifact2.getPath();
Path digestPath = diffDigest.getPath();
Path mtimePath = diffMtime.getPath();
writeFile(artifact1.getPath(), "content");
writeFile(artifact2.getPath(), "content");
path1.setLastModifiedTime(0);
path2.setLastModifiedTime(0);
// Same size as artifact1.
writeFile(diffDigest.getPath(), "1234567");
digestPath.setLastModifiedTime(0);
writeFile(mtimePath, "content");
mtimePath.setLastModifiedTime(1);
Path emptyPath1 = empty1.getPath();
Path emptyPath2 = empty2.getPath();
Path emptyPath3 = empty3.getPath();
writeFile(emptyPath1, "");
writeFile(emptyPath2, "");
writeFile(emptyPath3, "");
emptyPath1.setLastModifiedTime(0L);
emptyPath2.setLastModifiedTime(1L);
emptyPath3.setLastModifiedTime(1L);
Path dirPath1 = dir1.getPath();
Path dirPath2 = dir2.getPath();
Path dirPath3 = dir3.getPath();
FileSystemUtils.createDirectoryAndParents(dirPath1);
FileSystemUtils.createDirectoryAndParents(dirPath2);
FileSystemUtils.createDirectoryAndParents(dirPath3);
dirPath1.setLastModifiedTime(0L);
dirPath2.setLastModifiedTime(1L);
dirPath3.setLastModifiedTime(1L);
EqualsTester equalsTester = new EqualsTester();
equalsTester.addEqualityGroup(create(artifact1), create(artifact2), create(diffMtime)).addEqualityGroup(create(empty1), create(empty2), create(empty3)).addEqualityGroup(create(dir1)).addEqualityGroup(create(dir2), create(dir3)).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class ContainingPackageLookupFunctionTest method testEqualsAndHashCodeContract.
@Test
public void testEqualsAndHashCodeContract() throws Exception {
ContainingPackageLookupValue valueA1 = ContainingPackageLookupValue.NONE;
ContainingPackageLookupValue valueA2 = ContainingPackageLookupValue.NONE;
ContainingPackageLookupValue valueB1 = ContainingPackageLookupValue.withContainingPackage(PackageIdentifier.createInMainRepo("b"), rootDirectory);
ContainingPackageLookupValue valueB2 = ContainingPackageLookupValue.withContainingPackage(PackageIdentifier.createInMainRepo("b"), rootDirectory);
PackageIdentifier cFrag = PackageIdentifier.createInMainRepo("c");
ContainingPackageLookupValue valueC1 = ContainingPackageLookupValue.withContainingPackage(cFrag, rootDirectory);
ContainingPackageLookupValue valueC2 = ContainingPackageLookupValue.withContainingPackage(cFrag, rootDirectory);
ContainingPackageLookupValue valueCOther = ContainingPackageLookupValue.withContainingPackage(cFrag, rootDirectory.getRelative("other_root"));
new EqualsTester().addEqualityGroup(valueA1, valueA2).addEqualityGroup(valueB1, valueB2).addEqualityGroup(valueC1, valueC2).addEqualityGroup(valueCOther).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class FileFunctionTest method testFileValueHashCodeAndEqualsContract.
@Test
public void testFileValueHashCodeAndEqualsContract() throws Exception {
Path pathA = file(pkgRoot + "a", "a");
Path pathB = file(pkgRoot + "b", "b");
FileValue valueA1 = valueForPathOutsidePkgRoot(pathA);
FileValue valueA2 = valueForPathOutsidePkgRoot(pathA);
FileValue valueB1 = valueForPathOutsidePkgRoot(pathB);
FileValue valueB2 = valueForPathOutsidePkgRoot(pathB);
new EqualsTester().addEqualityGroup(valueA1, valueA2).addEqualityGroup(valueB1, valueB2).testEquals();
}
use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.
the class EntityQueryShould method support_equality.
@Test
public void support_equality() {
final EqualsTester tester = new EqualsTester();
addEqualityGroupA(tester);
addEqualityGroupB(tester);
addEqualityGroupC(tester);
addEqualityGroupD(tester);
tester.testEquals();
}
Aggregations