diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java b/src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java index cd2b3b96fc..853873386b 100644 --- a/src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java @@ -14,11 +14,8 @@ package com.google.devtools.build.lib.buildtool; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -114,22 +111,24 @@ public class SymlinkForestTest { @Test public void testLongestPathPrefix() { PathFragment a = PathFragment.create("A"); - assertEquals(a, longestPathPrefix("A/b", "A", "B")); // simple parent - assertEquals(a, longestPathPrefix("A", "A", "B")); // self - assertEquals(a.getRelative("B"), longestPathPrefix("A/B/c", "A", "A/B")); // want longest - assertNull(longestPathPrefix("C/b", "A", "B")); // not found in other parents - assertNull(longestPathPrefix("A", "A/B", "B")); // not found in child - assertEquals(a.getRelative("B/C"), longestPathPrefix("A/B/C/d/e/f.h", "A/B/C", "B/C/d")); - assertEquals(PathFragment.EMPTY_FRAGMENT, longestPathPrefix("A/f.h", "", "B/C/d")); + assertThat(longestPathPrefix("A/b", "A", "B")).isEqualTo(a); // simple parent + assertThat(longestPathPrefix("A", "A", "B")).isEqualTo(a); // self + assertThat(longestPathPrefix("A/B/c", "A", "A/B")) + .isEqualTo(a.getRelative("B")); // want longest + assertThat(longestPathPrefix("C/b", "A", "B")).isNull(); // not found in other parents + assertThat(longestPathPrefix("A", "A/B", "B")).isNull(); // not found in child + assertThat(longestPathPrefix("A/B/C/d/e/f.h", "A/B/C", "B/C/d")) + .isEqualTo(a.getRelative("B/C")); + assertThat(longestPathPrefix("A/f.h", "", "B/C/d")).isEqualTo(PathFragment.EMPTY_FRAGMENT); } @Test public void testDeleteTreesBelowNotPrefixed() throws IOException { createTestDirectoryTree(); SymlinkForest.deleteTreesBelowNotPrefixed(topDir, new String[]{"file-"}); - assertTrue(file1.exists()); - assertTrue(file2.exists()); - assertFalse(aDir.exists()); + assertThat(file1.exists()).isTrue(); + assertThat(file2.exists()).isTrue(); + assertThat(aDir.exists()).isFalse(); } private PackageIdentifier createPkg(Path rootA, Path rootB, String pkg) throws IOException { @@ -159,12 +158,12 @@ public class SymlinkForestTest { } private void assertLinksTo(Path fromRoot, Path toRoot) throws IOException { - assertTrue("stat: " + fromRoot.stat(), fromRoot.isSymbolicLink()); - assertEquals(toRoot.asFragment(), fromRoot.readSymbolicLink()); + assertWithMessage("stat: " + fromRoot.stat()).that(fromRoot.isSymbolicLink()).isTrue(); + assertThat(fromRoot.readSymbolicLink()).isEqualTo(toRoot.asFragment()); } private void assertIsDir(Path root, String relpart) { - assertTrue(root.getRelative(relpart).isDirectory(Symlinks.NOFOLLOW)); + assertThat(root.getRelative(relpart).isDirectory(Symlinks.NOFOLLOW)).isTrue(); } @Test @@ -243,7 +242,7 @@ public class SymlinkForestTest { new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname") .plantSymlinkForest(); - assertFalse(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/y/file").exists()); + assertThat(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/y/file").exists()).isFalse(); assertLinksTo( linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/y/w"), rootY.getRelative("w")); assertLinksTo( |