Search in sources :

Example 21 with PathFragment

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());
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 22 with PathFragment

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
    }
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 23 with PathFragment

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"));
}
Also used : ArrayList(java.util.ArrayList) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 24 with PathFragment

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));
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 25 with PathFragment

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());
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Aggregations

PathFragment (com.google.devtools.build.lib.vfs.PathFragment)512 Test (org.junit.Test)208 Artifact (com.google.devtools.build.lib.actions.Artifact)184 Path (com.google.devtools.build.lib.vfs.Path)111 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)65 SkyKey (com.google.devtools.build.skyframe.SkyKey)56 IOException (java.io.IOException)38 ArrayList (java.util.ArrayList)35 ImmutableList (com.google.common.collect.ImmutableList)32 Root (com.google.devtools.build.lib.actions.Root)32 HashMap (java.util.HashMap)27 Label (com.google.devtools.build.lib.cmdline.Label)26 LinkedHashMap (java.util.LinkedHashMap)26 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)23 ImmutableMap (com.google.common.collect.ImmutableMap)22 Map (java.util.Map)21 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)20 FilesetTraversalParams (com.google.devtools.build.lib.actions.FilesetTraversalParams)16 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)16 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)16