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());
}
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");
}
}
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) {
}
}
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();
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ArtifactTest method testSerializeToStringWithExecPath.
@Test
public void testSerializeToStringWithExecPath() throws Exception {
Path path = scratch.file("/aaa/bbb/ccc");
Root root = Root.asDerivedRoot(scratch.dir("/aaa/bbb"));
PathFragment execPath = new PathFragment("bbb/ccc");
assertEquals("bbb/ccc /3", new Artifact(path, root, execPath).serializeToString());
}
Aggregations