diff options
author | Janak Ramakrishnan <janakr@google.com> | 2016-07-02 18:13:52 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2016-07-04 07:19:33 +0000 |
commit | 870fb3fd151bd79a61c759b9835b70a8d815afeb (patch) | |
tree | 480e7fcc8024f45f5ed10e175ffbfe357db573b1 /src/test/java | |
parent | 2643c8e0df72685df3b24967019afbec03964380 (diff) |
Filter out already-removed deps when removing a node from the rdeps of its last build's deps. This is only an issue with cycles, since there we try to maintain the invariant that a parent is not done before its children by removing its deps on its children before we construct its cycle value.
--
MOS_MIGRATED_REVID=126494009
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java index 93c8f2b552..61c98215ff 100644 --- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java @@ -1325,6 +1325,58 @@ public class MemoizingEvaluatorTest { } @Test + public void nodeInvalidatedThenDoubleCycle() throws InterruptedException { + makeGraphDeterministic(); + // When topKey depends on depKey, and both are top-level nodes in the graph, + final SkyKey topKey = skyKey("bKey"); + final SkyKey depKey = skyKey("aKey"); + tester.getOrCreate(topKey).addDependency(depKey).setConstantValue(new StringValue("a")); + tester.getOrCreate(depKey).setConstantValue(new StringValue("b")); + // Then evaluation is as expected. + EvaluationResult<StringValue> result1 = tester.eval(/*keepGoing=*/ true, topKey, depKey); + assertThatEvaluationResult(result1).hasEntryThat(topKey).isEqualTo(new StringValue("a")); + assertThatEvaluationResult(result1).hasEntryThat(depKey).isEqualTo(new StringValue("b")); + assertThatEvaluationResult(result1).hasNoError(); + // When both nodes acquire self-edges, with topKey still also depending on depKey, in the same + // group, + tester.getOrCreate(depKey, /*markAsModified=*/ true).addDependency(depKey); + tester + .getOrCreate(topKey, /*markAsModified=*/ true) + .setConstantValue(null) + .removeDependency(depKey) + .setBuilder( + new SkyFunction() { + @Nullable + @Override + public SkyValue compute(SkyKey skyKey, Environment env) + throws SkyFunctionException, InterruptedException { + env.getValues(ImmutableList.of(topKey, depKey)); + assertThat(env.valuesMissing()).isTrue(); + return null; + } + + @Nullable + @Override + public String extractTag(SkyKey skyKey) { + return null; + } + }); + tester.invalidate(); + // Then evaluation is as expected -- topKey has removed its dep on depKey (since depKey was not + // done when topKey found its cycle), and both topKey and depKey have cycles. + EvaluationResult<StringValue> result2 = tester.eval(/*keepGoing=*/ true, topKey, depKey); + assertThatEvaluationResult(result2) + .hasErrorEntryForKeyThat(topKey) + .hasCycleInfoThat() + .containsExactly(new CycleInfo(ImmutableList.of(topKey))); + assertThatEvaluationResult(result2).hasDirectDepsInGraphThat(topKey).containsExactly(topKey); + assertThatEvaluationResult(result2) + .hasErrorEntryForKeyThat(depKey) + .hasCycleInfoThat() + .containsExactly(new CycleInfo(ImmutableList.of(depKey))); + } + + @Test public void limitEvaluatorThreads() throws Exception { initializeTester(); |