Search in sources :

Example 16 with Path

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

the class RootTest method testAsDerivedRoot.

@Test
public void testAsDerivedRoot() throws IOException {
    Path execRoot = scratch.dir("/exec");
    Path rootDir = scratch.dir("/exec/root");
    Root root = Root.asDerivedRoot(execRoot, rootDir);
    assertFalse(root.isSourceRoot());
    assertEquals(new PathFragment("root"), root.getExecPath());
    assertEquals(rootDir, root.getPath());
    assertEquals("/exec/root[derived]", root.toString());
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 17 with Path

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

the class ExecutableSymlinkActionTest method testSimple.

@Test
public void testSimple() throws Exception {
    Path inputFile = inputRoot.getPath().getChild("some-file");
    Path outputFile = outputRoot.getPath().getChild("some-output");
    FileSystemUtils.createEmptyFile(inputFile);
    inputFile.setExecutable(/*executable=*/
    true);
    Artifact input = new Artifact(inputFile, inputRoot);
    Artifact output = new Artifact(outputFile, outputRoot);
    ExecutableSymlinkAction action = new ExecutableSymlinkAction(NULL_ACTION_OWNER, input, output);
    action.execute(createContext());
    assertEquals(inputFile, outputFile.resolveSymbolicLinks());
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ExecutableSymlinkAction(com.google.devtools.build.lib.analysis.actions.ExecutableSymlinkAction) Test(org.junit.Test)

Example 18 with Path

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

the class ExecutableSymlinkActionTest method testFailIfInputIsNotAFile.

@Test
public void testFailIfInputIsNotAFile() throws Exception {
    Path dir = inputRoot.getPath().getChild("some-dir");
    FileSystemUtils.createDirectoryAndParents(dir);
    Artifact input = new Artifact(dir, inputRoot);
    Artifact output = new Artifact(outputRoot.getPath().getChild("some-output"), outputRoot);
    ExecutableSymlinkAction action = new ExecutableSymlinkAction(NULL_ACTION_OWNER, input, output);
    try {
        action.execute(createContext());
        fail();
    } catch (ActionExecutionException e) {
        assertThat(e.getMessage()).contains("'some-dir' is not a file");
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ExecutableSymlinkAction(com.google.devtools.build.lib.analysis.actions.ExecutableSymlinkAction) Test(org.junit.Test)

Example 19 with Path

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

the class ArtifactTest method testConstruction_badRootDir.

@Test
public void testConstruction_badRootDir() throws IOException {
    Path f1 = scratch.file("/exec/dir/file.ext");
    Path bogusDir = scratch.file("/exec/dir/bogus");
    try {
        new Artifact(f1, Root.asDerivedRoot(bogusDir), f1.relativeTo(execDir));
        fail("Expected IllegalArgumentException constructing artifact with a bad root dir");
    } catch (IllegalArgumentException expected) {
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Test(org.junit.Test)

Example 20 with Path

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

the class ArtifactTest method testRootPrefixedExecPaths.

@Test
public void testRootPrefixedExecPaths() throws IOException {
    Path f1 = scratch.file("/exec/root/dir/file1.ext");
    Path f2 = scratch.file("/exec/root/dir/dir/file2.ext");
    Path f3 = scratch.file("/exec/root/dir/dir/dir/file3.ext");
    Artifact a1 = new Artifact(f1, rootDir, f1.relativeTo(execDir));
    Artifact a2 = new Artifact(f2, rootDir, f2.relativeTo(execDir));
    Artifact a3 = new Artifact(f3, rootDir, f3.relativeTo(execDir));
    List<String> strings = new ArrayList<>();
    Artifact.addRootPrefixedExecPaths(Lists.newArrayList(a1, a2, a3), strings);
    assertThat(strings).containsExactly("root:dir/file1.ext", "root:dir/dir/file2.ext", "root:dir/dir/dir/file3.ext").inOrder();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ArrayList(java.util.ArrayList) 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