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