aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-05-15 13:07:01 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-15 13:08:16 -0700
commitf817134b2e39af6873255cecdda1a1d7ff38e090 (patch)
tree10d7c4e458bd4973c368145188f5aa8b3c0cc887 /src/test/java/com/google/devtools/build
parent17aebab3a6d17e6b691af6adaf374e07e4b9efe2 (diff)
Potentially allow children of a dirty node to be missing from the graph. Also pass the GraphInconsistencyReciever into SkyframeExecutor as a parameter.
PiperOrigin-RevId: 196716642
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java68
1 files changed, 68 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 807563a1eb..ef7ada37b2 100644
--- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
@@ -2424,6 +2424,74 @@ public class MemoizingEvaluatorTest {
RunResetNodeOnRequestWithDepsMode.NO_KEEP_EDGES_SO_NO_REEVALUATION);
}
+ private void missingDirtyChild(boolean sameGroup) throws Exception {
+ SkyKey topKey = GraphTester.skyKey("top");
+ SkyKey missingChild = GraphTester.skyKey("missing");
+ AtomicInteger numInconsistencyCalls = new AtomicInteger(0);
+ tester.setGraphInconsistencyReceiver(
+ (key, otherKey, inconsistency) -> {
+ Preconditions.checkState(missingChild.equals(otherKey), otherKey);
+ Preconditions.checkState(
+ inconsistency
+ == GraphInconsistencyReceiver.Inconsistency.CHILD_MISSING_FOR_DIRTY_NODE,
+ inconsistency);
+ Preconditions.checkState(topKey.equals(key), key);
+ numInconsistencyCalls.incrementAndGet();
+ });
+ tester.initialize(/*keepEdges=*/ true);
+ tester.getOrCreate(missingChild).setConstantValue(new StringValue("will go missing"));
+ SkyKey presentChild = GraphTester.skyKey("present");
+ tester.getOrCreate(presentChild).setConstantValue(new StringValue("present"));
+ StringValue topValue = new StringValue("top");
+ tester
+ .getOrCreate(topKey)
+ .setBuilder(
+ new SkyFunction() {
+ @Nullable
+ @Override
+ public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException {
+ if (sameGroup) {
+ env.getValues(ImmutableSet.of(presentChild, missingChild));
+ } else {
+ env.getValue(presentChild);
+ if (env.valuesMissing()) {
+ return null;
+ }
+ env.getValue(missingChild);
+ }
+ return env.valuesMissing() ? null : topValue;
+ }
+
+ @Nullable
+ @Override
+ public String extractTag(SkyKey skyKey) {
+ return null;
+ }
+ });
+ assertThat(tester.evalAndGet(/*keepGoing=*/ false, topKey)).isEqualTo(topValue);
+ deleteKeyFromGraph(missingChild);
+ tester
+ .getOrCreate(presentChild, /*markAsModified=*/ true)
+ .setConstantValue(new StringValue("changed"));
+ tester.invalidate();
+ assertThat(tester.evalAndGet(/*keepGoing=*/ false, topKey)).isEqualTo(topValue);
+ assertThat(numInconsistencyCalls.get()).isEqualTo(1);
+ }
+
+ protected void deleteKeyFromGraph(SkyKey key) {
+ ((InMemoryMemoizingEvaluator) tester.evaluator).getGraphForTesting().remove(key);
+ }
+
+ @Test
+ public void missingDirtyChild_SameGroup() throws Exception {
+ missingDirtyChild(/*sameGroup=*/ true);
+ }
+
+ @Test
+ public void missingDirtyChild_DifferentGroup() throws Exception {
+ missingDirtyChild(/*sameGroup=*/ false);
+ }
+
/**
* The same dep is requested in two groups, but its value determines what the other dep in the
* second group is. When it changes, the other dep in the second group should not be requested.