use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class ArtifactFactoryTest method testGetDerivedArtifact.
@Test
public void testGetDerivedArtifact() throws Exception {
PathFragment toolPath = new PathFragment("_bin/tool");
Artifact artifact = artifactFactory.getDerivedArtifact(toolPath, execRoot);
assertEquals(toolPath, artifact.getExecPath());
assertEquals(Root.asDerivedRoot(execRoot), artifact.getRoot());
assertEquals(execRoot.getRelative(toolPath), artifact.getPath());
assertNull(artifact.getOwner());
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class ArtifactFactoryTest method testGetDerivedArtifactFailsForAbsolutePath.
@Test
public void testGetDerivedArtifactFailsForAbsolutePath() throws Exception {
try {
artifactFactory.getDerivedArtifact(new PathFragment("/_bin/b"), execRoot);
fail();
} catch (IllegalArgumentException e) {
// Expected exception
}
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class ArtifactTest method testAddExpandedExecPaths.
@Test
public void testAddExpandedExecPaths() throws Exception {
List<PathFragment> paths = new ArrayList<>();
MutableActionGraph actionGraph = new MapBasedActionGraph();
Artifact.addExpandedExecPaths(getFooBarArtifacts(actionGraph, true), paths, ActionInputHelper.actionGraphArtifactExpander(actionGraph));
assertThat(paths).containsExactly(new PathFragment("bar1.h"), new PathFragment("bar1.h"), new PathFragment("bar2.h"), new PathFragment("bar3.h"));
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class ArtifactTest method testComparison.
@Test
public void testComparison() throws Exception {
PathFragment aPath = new PathFragment("src/a");
PathFragment bPath = new PathFragment("src/b");
Artifact aArtifact = new Artifact(aPath, rootDir);
Artifact bArtifact = new Artifact(bPath, rootDir);
assertEquals(-1, Artifact.EXEC_PATH_COMPARATOR.compare(aArtifact, bArtifact));
assertEquals(0, Artifact.EXEC_PATH_COMPARATOR.compare(aArtifact, aArtifact));
assertEquals(0, Artifact.EXEC_PATH_COMPARATOR.compare(bArtifact, bArtifact));
assertEquals(1, Artifact.EXEC_PATH_COMPARATOR.compare(bArtifact, aArtifact));
}
use of com.google.devtools.build.lib.vfs.PathFragment 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