Search in sources :

Example 96 with Path

use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.

the class SdkMavenRepositoryTest method testBuildFilesWritten.

@Test
public void testBuildFilesWritten() throws Exception {
    sdkMavenRepository.writeBuildFiles(workspaceDir);
    Path groupIdPath = scratch.resolve("com.google.android");
    assertThat(workspaceDir.getDirectoryEntries()).containsAllOf(repoPath, groupIdPath);
    Path buildFilePath = groupIdPath.getRelative("BUILD");
    assertThat(groupIdPath.getDirectoryEntries()).containsExactly(buildFilePath);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Test(org.junit.Test)

Example 97 with Path

use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.

the class SymlinkForestTest method testRemotePackage.

@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);
    FileSystemUtils.createEmptyFile(rootY.getRelative("file"));
    ImmutableMap<PackageIdentifier, Path> packageRootMap = ImmutableMap.<PackageIdentifier, Path>builder().put(createPkg(outputBase, "y", "w"), outputBase).put(createPkg(outputBase, "z", ""), outputBase).put(createPkg(outputBase, "z", "a/b/c"), outputBase).put(createPkg(outputBase, "w", ""), outputBase).build();
    new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname").plantSymlinkForest();
    assertFalse(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/y/file").exists());
    assertLinksTo(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/y/w"), rootY.getRelative("w"));
    assertLinksTo(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/z/file"), rootZ.getRelative("file"));
    assertLinksTo(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/z/a"), rootZ.getRelative("a"));
    assertLinksTo(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX + "/w/file"), rootW.getRelative("file"));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Test(org.junit.Test)

Example 98 with Path

use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.

the class SymlinkForestTest method testExternalPackage.

@Test
public void testExternalPackage() throws Exception {
    Path root = fileSystem.getPath("/src");
    ImmutableMap<PackageIdentifier, Path> packageRootMap = ImmutableMap.<PackageIdentifier, Path>builder().put(Label.EXTERNAL_PACKAGE_IDENTIFIER, root).build();
    new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname").plantSymlinkForest();
    assertThat(linkRoot.getRelative(Label.EXTERNAL_PATH_PREFIX).exists()).isFalse();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Test(org.junit.Test)

Example 99 with Path

use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.

the class SymlinkForestTest method testWorkspaceName.

@Test
public void testWorkspaceName() throws Exception {
    Path root = fileSystem.getPath("/src");
    ImmutableMap<PackageIdentifier, Path> packageRootMap = ImmutableMap.<PackageIdentifier, Path>builder().put(createPkg(root, "y", "w"), root).build();
    new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname").plantSymlinkForest();
    assertThat(linkRoot.getRelative("../wsname").exists()).isTrue();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Test(org.junit.Test)

Example 100 with Path

use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.

the class SymlinkForestTest method testPlantLinkForest.

@Test
public void testPlantLinkForest() throws IOException {
    Path rootA = fileSystem.getPath("/A");
    Path rootB = fileSystem.getPath("/B");
    ImmutableMap<PackageIdentifier, Path> packageRootMap = ImmutableMap.<PackageIdentifier, Path>builder().put(createPkg(rootA, rootB, "pkgA"), rootA).put(createPkg(rootA, rootB, "dir1/pkgA"), rootA).put(createPkg(rootA, rootB, "dir1/pkgB"), rootB).put(createPkg(rootA, rootB, "dir2/pkg"), rootA).put(createPkg(rootA, rootB, "dir2/pkg/pkg"), rootB).put(createPkg(rootA, rootB, "pkgB"), rootB).put(createPkg(rootA, rootB, "pkgB/dir/pkg"), rootA).put(createPkg(rootA, rootB, "pkgB/pkg"), rootA).put(createPkg(rootA, rootB, "pkgB/pkg/pkg"), rootA).build();
    // create a file in there
    createPkg(rootA, rootB, "pkgB/dir");
    Path linkRoot = fileSystem.getPath("/linkRoot");
    createDirectoryAndParents(linkRoot);
    new SymlinkForest(packageRootMap, linkRoot, TestConstants.PRODUCT_NAME, "wsname").plantSymlinkForest();
    assertLinksTo(linkRoot, rootA, "pkgA");
    assertIsDir(linkRoot, "dir1");
    assertLinksTo(linkRoot, rootA, "dir1/pkgA");
    assertLinksTo(linkRoot, rootB, "dir1/pkgB");
    assertIsDir(linkRoot, "dir2");
    assertIsDir(linkRoot, "dir2/pkg");
    assertLinksTo(linkRoot, rootA, "dir2/pkg/file");
    assertLinksTo(linkRoot, rootB, "dir2/pkg/pkg");
    assertIsDir(linkRoot, "pkgB");
    assertIsDir(linkRoot, "pkgB/dir");
    assertLinksTo(linkRoot, rootB, "pkgB/dir/file");
    assertLinksTo(linkRoot, rootA, "pkgB/dir/pkg");
    assertLinksTo(linkRoot, rootA, "pkgB/pkg");
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Test(org.junit.Test)

Aggregations

Path (com.google.devtools.build.lib.vfs.Path)492 Test (org.junit.Test)250 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)111 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)105 IOException (java.io.IOException)102 Artifact (com.google.devtools.build.lib.actions.Artifact)37 SkyKey (com.google.devtools.build.skyframe.SkyKey)37 ArrayList (java.util.ArrayList)29 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)17 FileSystem (com.google.devtools.build.lib.vfs.FileSystem)17 InMemoryFileSystem (com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem)17 HashMap (java.util.HashMap)17 WindowsPath (com.google.devtools.build.lib.windows.WindowsFileSystem.WindowsPath)16 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)14 Before (org.junit.Before)14 Package (com.google.devtools.build.lib.packages.Package)13 FileStatus (com.google.devtools.build.lib.vfs.FileStatus)13 Map (java.util.Map)12 Nullable (javax.annotation.Nullable)12 Executor (com.google.devtools.build.lib.actions.Executor)10