Search in sources :

Example 16 with EqualsTester

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();
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SequentialBuildDriver(com.google.devtools.build.skyframe.SequentialBuildDriver) SkyValue(com.google.devtools.build.skyframe.SkyValue) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 17 with EqualsTester

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();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) EqualsTester(com.google.common.testing.EqualsTester) SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) Artifact(com.google.devtools.build.lib.actions.Artifact) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) Test(org.junit.Test)

Example 18 with EqualsTester

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();
}
Also used : PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 19 with EqualsTester

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();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 20 with EqualsTester

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)225 Test (org.junit.Test)118 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 Test (org.junit.jupiter.api.Test)9 WildcardType (java.lang.reflect.WildcardType)8 Method (java.lang.reflect.Method)7 Entry (java.util.Map.Entry)7 GenericArrayType (java.lang.reflect.GenericArrayType)6 Type (java.lang.reflect.Type)6 HashMap (java.util.HashMap)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 List (java.util.List)5 DisplayName (org.junit.jupiter.api.DisplayName)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3