Search in sources :

Example 1 with WalkableGraph

use of com.google.devtools.build.skyframe.WalkableGraph in project bazel by bazelbuild.

the class RecursivePkgFunctionTest method testExcludedSubdirectoryGettingPassedDown.

@Test
public void testExcludedSubdirectoryGettingPassedDown() throws Exception {
    // Given a package "a" with two packages below a directory below it, "a/b/c" and "a/b/d",
    scratch.file("a/BUILD");
    scratch.file("a/b/c/BUILD");
    scratch.file("a/b/d/BUILD");
    // When the top package is evaluated for recursive package values, and "a/b/c" is excluded,
    ImmutableSet<PathFragment> excludedPaths = ImmutableSet.of(new PathFragment("a/b/c"));
    SkyKey key = buildRecursivePkgKey(rootDirectory, new PathFragment("a"), excludedPaths);
    EvaluationResult<RecursivePkgValue> evaluationResult = getEvaluationResult(key);
    RecursivePkgValue value = evaluationResult.get(key);
    // Then the package corresponding to the excluded subdirectory is not present in the result,
    assertThat(value.getPackages()).doesNotContain("a/b/c");
    // And the top package and other subsubdirectory package are.
    assertThat(value.getPackages()).contains("a");
    assertThat(value.getPackages()).contains("a/b/d");
    // Also, the computation graph contains a cached value for "a/b" with "a/b/c" excluded, because
    // "a/b/c" does live underneath "a/b".
    WalkableGraph graph = Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
    assertTrue(exists(buildRecursivePkgKey(rootDirectory, new PathFragment("a/b"), excludedPaths), graph));
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 2 with WalkableGraph

use of com.google.devtools.build.skyframe.WalkableGraph in project bazel by bazelbuild.

the class PrepareDepsOfPatternsFunctionTest method testDependencyTraversalNoSuchTargetException.

@Test
public void testDependencyTraversalNoSuchTargetException() throws Exception {
    // Given a package "//foo" with a target ":foo" that has a dependency on a non-existent target
    // "//bar:bar" in an existing package "//bar",
    createFooWithDependencyOnBarPackageWithMissingTarget();
    // Given a target pattern sequence consisting of a single-target pattern for "//foo",
    ImmutableList<String> patternSequence = ImmutableList.of("//foo");
    // When PrepareDepsOfPatternsFunction completes evaluation,
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
    // Then the graph contains an entry for ":foo" which has both a value and an exception,
    assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo")), /*expectTransitiveException=*/
    true);
    // And an entry with a NoSuchTargetException for "//bar:bar",
    Exception e = assertException(walkableGraph, getKeyForLabel(Label.create("@//bar", "bar")));
    assertThat(e).isInstanceOf(NoSuchTargetException.class);
}
Also used : WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph) NoSuchPackageException(com.google.devtools.build.lib.packages.NoSuchPackageException) IOException(java.io.IOException) NoSuchTargetException(com.google.devtools.build.lib.packages.NoSuchTargetException) Test(org.junit.Test)

Example 3 with WalkableGraph

use of com.google.devtools.build.skyframe.WalkableGraph in project bazel by bazelbuild.

the class PrepareDepsOfPatternsFunctionTest method testTargetParsingException.

@Test
public void testTargetParsingException() throws Exception {
    // Given no packages, and a target pattern sequence referring to a non-existent target,
    String nonexistentTarget = "//foo:foo";
    ImmutableList<String> patternSequence = ImmutableList.of(nonexistentTarget);
    // When PrepareDepsOfPatternsFunction completes evaluation,
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
    // Then the graph does not contain an entry for ":foo",
    assertFalse(exists(getKeyForLabel(Label.create("@//foo", "foo")), walkableGraph));
}
Also used : WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph) Test(org.junit.Test)

Example 4 with WalkableGraph

use of com.google.devtools.build.skyframe.WalkableGraph in project bazel by bazelbuild.

the class PrepareDepsOfPatternsFunctionTest method parsingProblem.

private void parsingProblem(boolean keepGoing) throws Exception {
    // Given a package "//foo" with target rule ":foo",
    createFooAndFoo2(/*dependent=*/
    false);
    // Given a target pattern sequence consisting of a pattern with parsing problems followed by
    // a legit target pattern,
    String bogusPattern = "//foo/....";
    ImmutableList<String> patternSequence = ImmutableList.of(bogusPattern, "//foo:foo");
    // When PrepareDepsOfPatternsFunction runs in the selected keep-going mode,
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence, /*keepGoing=*/
    keepGoing);
    // Then it skips evaluation of the malformed target pattern, but logs about it,
    assertContainsEvent("Skipping '" + bogusPattern + "': ");
    // And then the graph contains a value for the legit target pattern's target "@//foo:foo".
    assertTrue(exists(getKeyForLabel(Label.create("@//foo", "foo")), walkableGraph));
}
Also used : WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph)

Example 5 with WalkableGraph

use of com.google.devtools.build.skyframe.WalkableGraph in project bazel by bazelbuild.

the class PrepareDepsOfPatternsFunctionTest method testFunctionExpandsTargetPatterns.

@Test
public void testFunctionExpandsTargetPatterns() throws Exception {
    // Given a package "@//foo" with independent target rules ":foo" and ":foo2",
    createFooAndFoo2(/*dependent=*/
    false);
    // Given a target pattern sequence consisting of a pattern for "//foo:*",
    ImmutableList<String> patternSequence = ImmutableList.of("//foo:*");
    // When PrepareDepsOfPatternsFunction successfully completes evaluation,
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence);
    // Then the graph contains an entry for ":foo" and ":foo2".
    assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo")));
    assertValidValue(walkableGraph, getKeyForLabel(Label.create("@//foo", "foo2")));
}
Also used : WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph) Test(org.junit.Test)

Aggregations

WalkableGraph (com.google.devtools.build.skyframe.WalkableGraph)18 Test (org.junit.Test)13 SkyKey (com.google.devtools.build.skyframe.SkyKey)9 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)6 Label (com.google.devtools.build.lib.cmdline.Label)3 NoSuchPackageException (com.google.devtools.build.lib.packages.NoSuchPackageException)2 NoSuchTargetException (com.google.devtools.build.lib.packages.NoSuchTargetException)2 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Function (com.google.common.base.Function)1 Predicate (com.google.common.base.Predicate)1 ActionAnalysisMetadata (com.google.devtools.build.lib.actions.ActionAnalysisMetadata)1 ActionGraph (com.google.devtools.build.lib.actions.ActionGraph)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 ArtifactOwner (com.google.devtools.build.lib.actions.ArtifactOwner)1 TargetParsingException (com.google.devtools.build.lib.cmdline.TargetParsingException)1 Target (com.google.devtools.build.lib.packages.Target)1 ParseFailureListener (com.google.devtools.build.lib.pkgcache.ParseFailureListener)1 CoverageReportActionsWrapper (com.google.devtools.build.lib.rules.test.CoverageReportActionFactory.CoverageReportActionsWrapper)1