aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/skyframe
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-11-16 20:27:52 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-11-17 10:51:08 +0000
commita12ce278bdc17fe395b982d1ffd9ea598260563c (patch)
tree19ad16b9039d566d094f9ef3267042dcb4201851 /src/test/java/com/google/devtools/build/skyframe
parent71ab497f82130e5f7c682bea140de78a48088b4f (diff)
Add test for case when node is no longer needed, then explicitly evaluated, then depended on again.
-- MOS_MIGRATED_REVID=107965687
Diffstat (limited to 'src/test/java/com/google/devtools/build/skyframe')
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java41
1 files changed, 41 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 bce7dc2090..cea62e2276 100644
--- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
@@ -3690,6 +3690,47 @@ public class MemoizingEvaluatorTest {
assertThat(tester.evalAndGet(/*keepGoing=*/ true, top)).isEqualTo(new StringValue("leaf"));
}
+ // Tests that a removed and then reinstated node doesn't have a reverse dep on a former parent.
+ @Test
+ public void removedInvalidatedNodeComesBackAndOtherInvalidates() throws Exception {
+ SkyKey top = GraphTester.skyKey("top");
+ SkyKey leaf = GraphTester.skyKey("leaf");
+ // When top depends on leaf,
+ tester.getOrCreate(top).addDependency(leaf).setComputedValue(CONCATENATE);
+ StringValue leafValue = new StringValue("leaf");
+ tester.set(leaf, leafValue);
+ // Then when top is evaluated, its value is as expected.
+ assertThat(tester.evalAndGet(/*keepGoing=*/ true, top)).isEqualTo(leafValue);
+ // When top is changed to no longer depend on leaf,
+ StringValue topValue = new StringValue("top");
+ tester
+ .getOrCreate(top, /*markAsModified=*/ true)
+ .removeDependency(leaf)
+ .setComputedValue(null)
+ .setConstantValue(topValue);
+ // And leaf is invalidated,
+ tester.getOrCreate(leaf, /*markAsModified=*/ true);
+ // Then when top is evaluated, its value is as expected,
+ tester.invalidate();
+ assertThat(tester.evalAndGet(/*keepGoing=*/ true, top)).isEqualTo(topValue);
+ // And there is no value for leaf in the graph.
+ assertThat(tester.driver.getExistingValueForTesting(leaf)).isNull();
+ assertThat(tester.driver.getExistingErrorForTesting(leaf)).isNull();
+
+ // When leaf is evaluated, so that it is present in the graph again,
+ assertThat(tester.evalAndGet(/*keepGoing=*/ true, leaf)).isEqualTo(leafValue);
+ // And top is changed to depend on leaf again,
+ tester
+ .getOrCreate(top, /*markAsModified=*/ true)
+ .addDependency(leaf)
+ .setConstantValue(null)
+ .setComputedValue(CONCATENATE);
+ // Then when top is evaluated, its value is as expected.
+ tester.invalidate();
+ assertThat(tester.evalAndGet(/*keepGoing=*/ true, top)).isEqualTo(leafValue);
+ }
+
+
@Test
public void cleanReverseDepFromDirtyNodeNotInBuild() throws Exception {
final SkyKey topKey = GraphTester.skyKey("top");