diff options
author | 2017-05-30 12:35:33 +0200 | |
---|---|---|
committer | 2017-05-30 12:51:57 +0200 | |
commit | aea56b36af994b269800602e36000c293cabd00b (patch) | |
tree | 794f6b3b2528353cc39bd383730d408d4ff25233 /src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java | |
parent | 229f393bf460700594ae032a551879e026bd0b91 (diff) |
Migrate Java tests to Truth.
RELNOTES: None.
PiperOrigin-RevId: 157446717
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java index ff5b2bdeee..7e770ffe81 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java @@ -14,11 +14,8 @@ package com.google.devtools.build.lib.skyframe; +import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.skyframe.EvaluationResultSubjectFactory.assertThatEvaluationResult; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -174,18 +171,18 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { public void testNoBuildFile() throws Exception { scratch.file("parentpackage/nobuildfile/foo.txt"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/nobuildfile"); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.NO_BUILD_FILE, packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.NO_BUILD_FILE); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } @Test public void testNoBuildFileAndNoParentPackage() throws Exception { scratch.file("noparentpackage/foo.txt"); PackageLookupValue packageLookupValue = lookupPackage("noparentpackage"); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.NO_BUILD_FILE, packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.NO_BUILD_FILE); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } @Test @@ -194,9 +191,9 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { deletedPackages.set(ImmutableSet.of( PackageIdentifier.createInMainRepo("parentpackage/deletedpackage"))); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/deletedpackage"); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.DELETED_PACKAGE, packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.DELETED_PACKAGE); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } @@ -211,9 +208,9 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { ImmutableSet<String> pkgs = ImmutableSet.of("blacklisted/subdir", "blacklisted"); for (String pkg : pkgs) { PackageLookupValue packageLookupValue = lookupPackage(pkg); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.DELETED_PACKAGE, packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.DELETED_PACKAGE); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } scratch.overwriteFile("config/blacklisted.txt", "not_blacklisted"); @@ -223,7 +220,7 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { differencer.invalidate(ImmutableSet.of(FileStateValue.key(rootedBlacklist))); for (String pkg : pkgs) { PackageLookupValue packageLookupValue = lookupPackage(pkg); - assertTrue(packageLookupValue.packageExists()); + assertThat(packageLookupValue.packageExists()).isTrue(); } } @@ -231,38 +228,36 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { public void testInvalidPackageName() throws Exception { scratch.file("parentpackage/invalidpackagename%42/BUILD"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/invalidpackagename%42"); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.INVALID_PACKAGE_NAME, - packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.INVALID_PACKAGE_NAME); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } @Test public void testDirectoryNamedBuild() throws Exception { scratch.dir("parentpackage/isdirectory/BUILD"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/isdirectory"); - assertFalse(packageLookupValue.packageExists()); - assertEquals(ErrorReason.NO_BUILD_FILE, - packageLookupValue.getErrorReason()); - assertNotNull(packageLookupValue.getErrorMsg()); + assertThat(packageLookupValue.packageExists()).isFalse(); + assertThat(packageLookupValue.getErrorReason()).isEqualTo(ErrorReason.NO_BUILD_FILE); + assertThat(packageLookupValue.getErrorMsg()).isNotNull(); } @Test public void testEverythingIsGood_BUILD() throws Exception { scratch.file("parentpackage/everythinggood/BUILD"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/everythinggood"); - assertTrue(packageLookupValue.packageExists()); - assertEquals(rootDirectory, packageLookupValue.getRoot()); - assertEquals(BuildFileName.BUILD, packageLookupValue.getBuildFileName()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(rootDirectory); + assertThat(packageLookupValue.getBuildFileName()).isEqualTo(BuildFileName.BUILD); } @Test public void testEverythingIsGood_BUILD_bazel() throws Exception { scratch.file("parentpackage/everythinggood/BUILD.bazel"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/everythinggood"); - assertTrue(packageLookupValue.packageExists()); - assertEquals(rootDirectory, packageLookupValue.getRoot()); - assertEquals(BuildFileName.BUILD_DOT_BAZEL, packageLookupValue.getBuildFileName()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(rootDirectory); + assertThat(packageLookupValue.getBuildFileName()).isEqualTo(BuildFileName.BUILD_DOT_BAZEL); } @Test @@ -270,9 +265,9 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { scratch.file("parentpackage/everythinggood/BUILD"); scratch.file("parentpackage/everythinggood/BUILD.bazel"); PackageLookupValue packageLookupValue = lookupPackage("parentpackage/everythinggood"); - assertTrue(packageLookupValue.packageExists()); - assertEquals(rootDirectory, packageLookupValue.getRoot()); - assertEquals(BuildFileName.BUILD_DOT_BAZEL, packageLookupValue.getBuildFileName()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(rootDirectory); + assertThat(packageLookupValue.getBuildFileName()).isEqualTo(BuildFileName.BUILD_DOT_BAZEL); } @Test @@ -282,18 +277,18 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { // BUILD file in the first package path should be preferred to BUILD.bazel in the second. PackageLookupValue packageLookupValue = lookupPackage("foo"); - assertTrue(packageLookupValue.packageExists()); - assertEquals(emptyPackagePath, packageLookupValue.getRoot()); - assertEquals(BuildFileName.BUILD, packageLookupValue.getBuildFileName()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(emptyPackagePath); + assertThat(packageLookupValue.getBuildFileName()).isEqualTo(BuildFileName.BUILD); } @Test public void testEmptyPackageName() throws Exception { scratch.file("BUILD"); PackageLookupValue packageLookupValue = lookupPackage(""); - assertTrue(packageLookupValue.packageExists()); - assertEquals(rootDirectory, packageLookupValue.getRoot()); - assertEquals(BuildFileName.BUILD, packageLookupValue.getBuildFileName()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(rootDirectory); + assertThat(packageLookupValue.getBuildFileName()).isEqualTo(BuildFileName.BUILD); } @Test @@ -301,8 +296,8 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { scratch.overwriteFile("WORKSPACE"); PackageLookupValue packageLookupValue = lookupPackage( PackageIdentifier.createInMainRepo("external")); - assertTrue(packageLookupValue.packageExists()); - assertEquals(rootDirectory, packageLookupValue.getRoot()); + assertThat(packageLookupValue.packageExists()).isTrue(); + assertThat(packageLookupValue.getRoot()).isEqualTo(rootDirectory); } @Test @@ -340,11 +335,11 @@ public abstract class PackageLookupFunctionTest extends FoundationTestCase { // First, use the correct label. PackageLookupValue packageLookupValue = lookupPackage(PackageIdentifier.create("@local", PathFragment.EMPTY_FRAGMENT)); - assertTrue(packageLookupValue.packageExists()); + assertThat(packageLookupValue.packageExists()).isTrue(); // Then, use the incorrect label. packageLookupValue = lookupPackage(PackageIdentifier.createInMainRepo("local/repo")); - assertEquals(expectedPackageExists, packageLookupValue.packageExists()); + assertThat(packageLookupValue.packageExists()).isEqualTo(expectedPackageExists); } /** |