Search in sources :

Example 36 with PathFragment

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

the class TreeArtifactMetadataTest method createTreeArtifact.

private Artifact createTreeArtifact(String path) throws IOException {
    PathFragment execPath = new PathFragment("out").getRelative(path);
    Path fullPath = root.getRelative(execPath);
    Artifact output = new SpecialArtifact(fullPath, Root.asDerivedRoot(root, root.getRelative("out")), execPath, ALL_OWNER, SpecialArtifactType.TREE);
    actions.add(new DummyAction(ImmutableList.<Artifact>of(), output));
    FileSystemUtils.createDirectoryAndParents(fullPath);
    return output;
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) DummyAction(com.google.devtools.build.lib.actions.util.TestAction.DummyAction) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) Artifact(com.google.devtools.build.lib.actions.Artifact) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)

Example 37 with PathFragment

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

the class PrepareDepsOfPatternsFunctionSmartNegationTest method testBlacklistPatternBlocksPatternEvaluation.

@Test
public void testBlacklistPatternBlocksPatternEvaluation() throws Exception {
    // Given a well-formed package "//foo" and a malformed package "//foo/foo",
    createFooAndFooFoo();
    // Given a target pattern sequence consisting of a recursive pattern for "//foo/...",
    ImmutableList<String> patternSequence = ImmutableList.of("//foo/...");
    // and a blacklist for the malformed package,
    getSkyframeExecutor().setBlacklistedPackagePrefixesFile(new PathFragment("config/blacklist.txt"));
    scratch.file("config/blacklist.txt", "foo/foo");
    assertSkipsFoo(patternSequence);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 38 with PathFragment

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

the class RecursiveFilesystemTraversalFunctionTest method derivedArtifact.

private Artifact derivedArtifact(String path) {
    PathFragment execPath = new PathFragment("out").getRelative(path);
    Path fullPath = rootDirectory.getRelative(execPath);
    Artifact output = new Artifact(fullPath, Root.asDerivedRoot(rootDirectory, rootDirectory.getRelative("out")), execPath);
    return output;
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 39 with PathFragment

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

the class RecursiveFilesystemTraversalFunctionTest method testTraversalOfTransitiveSymlinkToFile.

@Test
public void testTraversalOfTransitiveSymlinkToFile() throws Exception {
    Artifact directLinkArtifact = sourceArtifact("direct/file.sym");
    Artifact transitiveLinkArtifact = sourceArtifact("transitive/sym.sym");
    RootedPath fileA = createFile(rootedPath(sourceArtifact("a/file.a")));
    RootedPath directLink = rootedPath(directLinkArtifact);
    RootedPath transitiveLink = rootedPath(transitiveLinkArtifact);
    PathFragment directLinkPath = new PathFragment("../a/file.a");
    PathFragment transitiveLinkPath = new PathFragment("../direct/file.sym");
    parentOf(directLink).asPath().createDirectory();
    parentOf(transitiveLink).asPath().createDirectory();
    directLink.asPath().createSymbolicLink(directLinkPath);
    transitiveLink.asPath().createSymbolicLink(transitiveLinkPath);
    traverseAndAssertFiles(fileLikeRoot(directLinkArtifact, DONT_CROSS), symlinkToFileForTesting(fileA, directLink, directLinkPath));
    traverseAndAssertFiles(fileLikeRoot(transitiveLinkArtifact, DONT_CROSS), symlinkToFileForTesting(fileA, transitiveLink, transitiveLinkPath));
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 40 with PathFragment

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

the class RecursiveFilesystemTraversalFunctionTest method testTraversalOfTransitiveSymlinkToDirectory.

@Test
public void testTraversalOfTransitiveSymlinkToDirectory() throws Exception {
    Artifact directLinkArtifact = sourceArtifact("direct/dir.sym");
    Artifact transitiveLinkArtifact = sourceArtifact("transitive/sym.sym");
    RootedPath fileA = createFile(rootedPath(sourceArtifact("a/file.a")));
    RootedPath directLink = rootedPath(directLinkArtifact);
    RootedPath transitiveLink = rootedPath(transitiveLinkArtifact);
    PathFragment directLinkPath = new PathFragment("../a");
    PathFragment transitiveLinkPath = new PathFragment("../direct/dir.sym");
    parentOf(directLink).asPath().createDirectory();
    parentOf(transitiveLink).asPath().createDirectory();
    directLink.asPath().createSymbolicLink(directLinkPath);
    transitiveLink.asPath().createSymbolicLink(transitiveLinkPath);
    // Expect the file as if was a child of the direct symlink, not of the actual directory.
    traverseAndAssertFiles(fileLikeRoot(directLinkArtifact, DONT_CROSS), symlinkToDirectoryForTesting(parentOf(fileA), directLink, directLinkPath), regularFileForTesting(childOf(directLinkArtifact, "file.a")));
    // Expect the file as if was a child of the transitive symlink, not of the actual directory.
    traverseAndAssertFiles(fileLikeRoot(transitiveLinkArtifact, DONT_CROSS), symlinkToDirectoryForTesting(parentOf(fileA), transitiveLink, transitiveLinkPath), regularFileForTesting(childOf(transitiveLinkArtifact, "file.a")));
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) 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