Add a bit more testing coverage to MemoizingEvaluatorTest.
--
MOS_MIGRATED_REVID=102265945
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 c75af92..7d7cebe 100644
--- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java
@@ -264,6 +264,18 @@
}
@Test
+ public void deleteDirtyCleanedValue() throws Exception {
+ SkyKey leafKey = GraphTester.skyKey("leafKey");
+ tester.getOrCreate(leafKey).setConstantValue(new StringValue("value"));
+ SkyKey topKey = GraphTester.skyKey("topKey");
+ tester.getOrCreate(topKey).addDependency(leafKey).setComputedValue(CONCATENATE);
+
+ assertThat(tester.evalAndGet(/*keepGoing=*/false, topKey)).isEqualTo(new StringValue("value"));
+ failBuildAndRemoveValue(leafKey);
+ tester.evaluator.deleteDirty(0);
+ }
+
+ @Test
public void deleteNonexistentValues() throws Exception {
tester.getOrCreate("d1").setConstantValue(new StringValue("1"));
tester.delete("d1");
@@ -1466,7 +1478,8 @@
new DeterministicInMemoryGraph(
new Listener() {
@Override
- public void accept(SkyKey key, EventType type, Order order, Object context) {
+ public void accept(
+ SkyKey key, EventType type, Order order, @Nullable Object context) {
if (!delayTopSignaling.get()) {
return;
}
@@ -1478,7 +1491,7 @@
}
if (key.equals(slowAddingDep)
&& type == EventType.ADD_REVERSE_DEP
- && context.equals(top)
+ && top.equals(context)
&& order == Order.BEFORE) {
// If top is trying to declare a dep on slowAddingDep, wait until firstKey has
// signaled top. Then this add dep will return DONE and top will be signaled,
@@ -1564,6 +1577,25 @@
dirtyChildEnqueuesParentDuringCheckDependencies(/*throwError=*/false);
}
+ @Test
+ public void dirtyThenDeleted() throws Exception {
+ initializeTester();
+ SkyKey topKey = GraphTester.skyKey("top");
+ SkyKey leafKey = GraphTester.skyKey("leaf");
+ tester.getOrCreate(topKey).addDependency(leafKey).setComputedValue(CONCATENATE);
+ tester.set(leafKey, new StringValue("leafy"));
+ assertThat(tester.evalAndGet(/*keepGoing=*/false, topKey)).isEqualTo(new StringValue("leafy"));
+ tester.getOrCreate(topKey, /*markAsModified=*/true);
+ tester.invalidate();
+ assertThat(tester.evalAndGet(/*keepGoing=*/false, leafKey))
+ .isEqualTo(new StringValue("leafy"));
+ tester.delete("top");
+ tester.getOrCreate(leafKey, /*markAsModified=*/true);
+ tester.invalidate();
+ assertThat(tester.evalAndGet(/*keepGoing=*/false, leafKey))
+ .isEqualTo(new StringValue("leafy"));
+ }
+
/**
* 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.
@@ -2456,7 +2488,7 @@
// -> some top key builds.
result = tester.eval(/*keepGoing=*/false, topErrorFirstKey, topBubbleKey);
assertTrue(result.hasError());
- assertNotNull(result.getError(topErrorFirstKey));
+ assertWithMessage(result.toString()).that(result.getError(topErrorFirstKey)).isNotNull();
}
@Test
@@ -3089,12 +3121,18 @@
return null;
}
});
- tester.eval(/*keepGoing=*/false, cachedParentKey, uncachedParentKey, waitForShutdownKey);
+ EvaluationResult<StringValue> result =
+ tester.eval(/*keepGoing=*/false, cachedParentKey, uncachedParentKey, waitForShutdownKey);
+ assertWithMessage(result.toString()).that(result.hasError()).isTrue();
Pair<SkyKey, ? extends Exception> unexpected = unexpectedException.get();
if (unexpected != null) {
throw new AssertionError(unexpected.first + ", " + unexpected.second + ", "
+ Arrays.toString(unexpected.second.getStackTrace()));
}
+ tester.getOrCreate(invalidatedKey, /*markAsModified=*/true);
+ tester.invalidate();
+ result = tester.eval(/*keepGoing=*/false, cachedParentKey, uncachedParentKey);
+ assertWithMessage(result.toString()).that(result.hasError()).isTrue();
}
@Test