aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-01-17 14:36:26 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-17 14:37:59 -0800
commitee6a6862e26704854fb08bd90912890814cc3426 (patch)
tree294eac82202e393c5baae0e357325f2488ab3cbb /src/test/java/com/google/devtools/build/lib/buildtool/SymlinkForestTest.java
parentf323fb3043bc782526e0e47933efedea9c5c2ad9 (diff)
Introduce Root class.
This class represents a root (such as a package path or an output root) used for file lookups and artifacts. It is meant to be as opaque as possible in order to hide the user's environment from sky keys and sky functions. Roots are used by RootedPaths and ArtifactRoots. This CL attempts to make the minimum number of modifications necessary to change RootedPath and ArtifactRoot to use these fields. Deprecated methods and invasive accessors are permitted to minimise the risk of any observable changes. RELNOTES: None PiperOrigin-RevId: 182271759
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.java51
1 files changed, 26 insertions, 25 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 853873386b..ab550a072d 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
@@ -29,6 +29,7 @@ import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
+import com.google.devtools.build.lib.vfs.Root;
import com.google.devtools.build.lib.vfs.Symlinks;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
@@ -131,7 +132,7 @@ public class SymlinkForestTest {
assertThat(aDir.exists()).isFalse();
}
- private PackageIdentifier createPkg(Path rootA, Path rootB, String pkg) throws IOException {
+ private PackageIdentifier createPkg(Root rootA, Root rootB, String pkg) throws IOException {
if (rootA != null) {
createDirectoryAndParents(rootA.getRelative(pkg));
FileSystemUtils.createEmptyFile(rootA.getRelative(pkg).getChild("file"));
@@ -143,7 +144,7 @@ public class SymlinkForestTest {
return PackageIdentifier.createInMainRepo(pkg);
}
- private PackageIdentifier createPkg(Path root, String repo, String pkg)
+ private PackageIdentifier createPkg(Root root, String repo, String pkg)
throws IOException, LabelSyntaxException {
if (root != null) {
Path repoRoot = root.getRelative(Label.EXTERNAL_PACKAGE_NAME).getRelative(repo);
@@ -153,7 +154,7 @@ public class SymlinkForestTest {
return PackageIdentifier.create(RepositoryName.create("@" + repo), PathFragment.create(pkg));
}
- private void assertLinksTo(Path fromRoot, Path toRoot, String relpart) throws IOException {
+ private void assertLinksTo(Path fromRoot, Root toRoot, String relpart) throws IOException {
assertLinksTo(fromRoot.getRelative(relpart), toRoot.getRelative(relpart));
}
@@ -168,11 +169,11 @@ public class SymlinkForestTest {
@Test
public void testPlantLinkForest() throws IOException {
- Path rootA = fileSystem.getPath("/A");
- Path rootB = fileSystem.getPath("/B");
+ Root rootA = Root.fromPath(fileSystem.getPath("/A"));
+ Root rootB = Root.fromPath(fileSystem.getPath("/B"));
- ImmutableMap<PackageIdentifier, Path> packageRootMap =
- ImmutableMap.<PackageIdentifier, Path>builder()
+ ImmutableMap<PackageIdentifier, Root> packageRootMap =
+ ImmutableMap.<PackageIdentifier, Root>builder()
.put(createPkg(rootA, rootB, "pkgA"), rootA)
.put(createPkg(rootA, rootB, "dir1/pkgA"), rootA)
.put(createPkg(rootA, rootB, "dir1/pkgB"), rootB)
@@ -207,10 +208,10 @@ public class SymlinkForestTest {
@Test
public void testTopLevelPackage() throws Exception {
- Path rootX = fileSystem.getPath("/X");
- Path rootY = fileSystem.getPath("/Y");
- ImmutableMap<PackageIdentifier, Path> packageRootMap =
- ImmutableMap.<PackageIdentifier, Path>builder()
+ Root rootX = Root.fromPath(fileSystem.getPath("/X"));
+ Root rootY = Root.fromPath(fileSystem.getPath("/Y"));
+ ImmutableMap<PackageIdentifier, Root> packageRootMap =
+ ImmutableMap.<PackageIdentifier, Root>builder()
.put(createPkg(rootX, rootY, ""), rootX)
.put(createPkg(rootX, rootY, "foo"), rootX)
.build();
@@ -222,15 +223,15 @@ public class SymlinkForestTest {
@Test
public void testRemotePackage() throws Exception {
- Path outputBase = fileSystem.getPath("/ob");
- Path rootY = outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("y");
- Path rootZ = outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("z");
- Path rootW = outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("w");
- createDirectoryAndParents(rootY);
+ Root outputBase = Root.fromPath(fileSystem.getPath("/ob"));
+ Root rootY = Root.fromPath(outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("y"));
+ Root rootZ = Root.fromPath(outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("z"));
+ Root rootW = Root.fromPath(outputBase.getRelative(Label.EXTERNAL_PATH_PREFIX).getRelative("w"));
+ createDirectoryAndParents(rootY.asPath());
FileSystemUtils.createEmptyFile(rootY.getRelative("file"));
- ImmutableMap<PackageIdentifier, Path> packageRootMap =
- ImmutableMap.<PackageIdentifier, Path>builder()
+ ImmutableMap<PackageIdentifier, Root> packageRootMap =
+ ImmutableMap.<PackageIdentifier, Root>builder()
// Remote repo without top-level package.
.put(createPkg(outputBase, "y", "w"), outputBase)
// Remote repo with and without top-level package.
@@ -256,9 +257,9 @@ public class SymlinkForestTest {
@Test
public void testExternalPackage() throws Exception {
- Path root = fileSystem.getPath("/src");
- ImmutableMap<PackageIdentifier, Path> packageRootMap =
- ImmutableMap.<PackageIdentifier, Path>builder()
+ Root root = Root.fromPath(fileSystem.getPath("/src"));
+ ImmutableMap<PackageIdentifier, Root> packageRootMap =
+ ImmutableMap.<PackageIdentifier, Root>builder()
// Virtual root, shouldn't actually be linked in.
.put(Label.EXTERNAL_PACKAGE_IDENTIFIER, root)
.build();
@@ -270,9 +271,9 @@ public class SymlinkForestTest {
@Test
public void testWorkspaceName() throws Exception {
- Path root = fileSystem.getPath("/src");
- ImmutableMap<PackageIdentifier, Path> packageRootMap =
- ImmutableMap.<PackageIdentifier, Path>builder()
+ Root root = Root.fromPath(fileSystem.getPath("/src"));
+ ImmutableMap<PackageIdentifier, Root> packageRootMap =
+ ImmutableMap.<PackageIdentifier, Root>builder()
// Remote repo without top-level package.
.put(createPkg(root, "y", "w"), root)
.build();
@@ -284,7 +285,7 @@ public class SymlinkForestTest {
@Test
public void testExecrootVersionChanges() throws Exception {
- ImmutableMap<PackageIdentifier, Path> packageRootMap = ImmutableMap.of();
+ ImmutableMap<PackageIdentifier, Root> packageRootMap = ImmutableMap.of();
linkRoot.getRelative("wsname").createDirectory();
new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname")
.plantSymlinkForest();