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();
}
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));
}
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));
}
Aggregations