Search in sources :

Example 16 with WalkableGraph

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

the class PrepareDepsOfTargetsUnderDirectoryFunctionTest method testTransitiveLoading.

@Test
public void testTransitiveLoading() throws Exception {
    // Given a package "a" with a genrule "a" that depends on a target in package "b",
    createPackages();
    // When package "a" is evaluated,
    SkyKey key = createPrepDepsKey(rootDirectory, new PathFragment("a"));
    EvaluationResult<?> evaluationResult = getEvaluationResult(key);
    WalkableGraph graph = Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
    // Then the TransitiveTraversalValue for "@//a:a" is evaluated,
    SkyKey aaKey = TransitiveTraversalValue.key(Label.create("@//a", "a"));
    assertThat(exists(aaKey, graph)).isTrue();
    // And that TransitiveTraversalValue depends on "@//b:b.txt".
    Iterable<SkyKey> depsOfAa = Iterables.getOnlyElement(graph.getDirectDeps(ImmutableList.of(aaKey)).values());
    SkyKey bTxtKey = TransitiveTraversalValue.key(Label.create("@//b", "b.txt"));
    assertThat(depsOfAa).contains(bTxtKey);
    // And the TransitiveTraversalValue for "b:b.txt" is evaluated.
    assertThat(exists(bTxtKey, graph)).isTrue();
}
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 17 with WalkableGraph

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

the class PrepareDepsOfPatternsFunctionSmartNegationTest method assertSkipsFoo.

private void assertSkipsFoo(ImmutableList<String> patternSequence) throws Exception {
    // When PrepareDepsOfPatternsFunction completes evaluation (successfully),
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence, /*successExpected=*/
    true, /*keepGoing=*/
    true);
    // Then the graph contains a package value for "@//foo",
    assertTrue(exists(PackageValue.key(PackageIdentifier.parse("@//foo")), walkableGraph));
    // But no package value for "@//foo/foo",
    assertFalse(exists(PackageValue.key(PackageIdentifier.parse("@//foo/foo")), walkableGraph));
    // And the graph does not contain a value for the target "@//foo/foo:foofoo".
    Label label = Label.create("@//foo/foo", "foofoo");
    assertFalse(exists(getKeyForLabel(label), walkableGraph));
}
Also used : WalkableGraph(com.google.devtools.build.skyframe.WalkableGraph) Label(com.google.devtools.build.lib.cmdline.Label)

Example 18 with WalkableGraph

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

the class PrepareDepsOfPatternsFunctionSmartNegationTest method testRecursiveEvaluationFailsOnBadBuildFile.

@Test
public void testRecursiveEvaluationFailsOnBadBuildFile() 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/...");
    // When PrepareDepsOfPatternsFunction completes evaluation (with no error because it was
    // recovered from),
    WalkableGraph walkableGraph = getGraphFromPatternsEvaluation(patternSequence, /*successExpected=*/
    true, /*keepGoing=*/
    true);
    // Then the graph contains package values for "@//foo" and "@//foo/foo",
    assertTrue(exists(PackageValue.key(PackageIdentifier.parse("@//foo")), walkableGraph));
    assertTrue(exists(PackageValue.key(PackageIdentifier.parse("@//foo/foo")), walkableGraph));
    // But the graph does not contain a value for the target "@//foo/foo:foofoo".
    assertFalse(exists(getKeyForLabel(Label.create("@//foo/foo", "foofoo")), walkableGraph));
}
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