use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method deleteDirtyCleanedValue.
@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);
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method manyDirtyValuesClearChildrenOnSecondFail.
/**
* Regression test: child value that has been deleted since it and its parent were marked dirty no
* longer knows it has a reverse dep on its parent.
*
* <p>Start with:
* <pre>
* top0 ... top1000
* \ | /
* leaf
* </pre>
* Then fail to build leaf. Now the entry for leaf should have no "memory" that it was ever
* depended on by tops. Now build tops, but fail again.
*/
@Test
public void manyDirtyValuesClearChildrenOnSecondFail() throws Exception {
final SkyKey leafKey = GraphTester.toSkyKey("leaf");
tester.set(leafKey, new StringValue("leafy"));
SkyKey lastKey = GraphTester.toSkyKey("last");
tester.set(lastKey, new StringValue("last"));
final List<SkyKey> tops = new ArrayList<>();
// the leaf child is enqueued for processing.
for (int i = 0; i < 10000; i++) {
SkyKey topKey = GraphTester.toSkyKey("top" + i);
tester.getOrCreate(topKey).addDependency(leafKey).addDependency(lastKey).setComputedValue(CONCATENATE);
tops.add(topKey);
}
tester.eval(/*keepGoing=*/
false, tops.toArray(new SkyKey[0]));
failBuildAndRemoveValue(leafKey);
// Request the tops. Since leaf was deleted from the graph last build, it no longer knows that
// its parents depend on it. When leaf throws, at least one of its parents (hopefully) will not
// have re-informed leaf that the parent depends on it, exposing the bug, since the parent
// should then not try to clean the reverse dep from leaf.
tester.set(leafKey, null);
// Evaluator will think leaf was interrupted because it threw, so it will be cleaned from graph.
tester.getOrCreate(leafKey, /*markAsModified=*/
true).setBuilder(INTERRUPT_BUILDER);
tester.invalidate();
try {
tester.eval(/*keepGoing=*/
false, tops.toArray(new SkyKey[0]));
Assert.fail();
} catch (InterruptedException e) {
// Expected.
}
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method persistentErrorsNotRerun.
@Test
public void persistentErrorsNotRerun() throws Exception {
SkyKey topKey = GraphTester.toSkyKey("top");
SkyKey transientErrorKey = GraphTester.toSkyKey("transientError");
SkyKey persistentErrorKey1 = GraphTester.toSkyKey("persistentError1");
SkyKey persistentErrorKey2 = GraphTester.toSkyKey("persistentError2");
tester.getOrCreate(topKey).addErrorDependency(transientErrorKey, new StringValue("doesn't matter")).addErrorDependency(persistentErrorKey1, new StringValue("doesn't matter")).setHasError(true);
tester.getOrCreate(persistentErrorKey1).setHasError(true);
tester.getOrCreate(transientErrorKey).addErrorDependency(persistentErrorKey2, new StringValue("doesn't matter")).setHasTransientError(true);
tester.getOrCreate(persistentErrorKey2).setHasError(true);
tester.evalAndGetError(topKey);
assertThat(tester.getEnqueuedValues()).containsExactly(topKey, transientErrorKey, persistentErrorKey1, persistentErrorKey2);
tester.invalidate();
tester.invalidateTransientErrors();
tester.evalAndGetError(topKey);
// TODO(bazel-team): We can do better here once we implement change pruning for errors.
assertThat(tester.getEnqueuedValues()).containsExactly(topKey, transientErrorKey);
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method errorTransienceDepCleared.
/** Regression test for crash bug. */
@Test
public void errorTransienceDepCleared() throws Exception {
initializeTester();
final SkyKey top = GraphTester.toSkyKey("top");
SkyKey leaf = GraphTester.toSkyKey("leaf");
tester.set(leaf, new StringValue("leaf"));
tester.getOrCreate(top).addDependency(leaf).setHasTransientError(true);
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
false, top);
assertTrue(result.toString(), result.hasError());
tester.getOrCreate(leaf, /*markAsModified=*/
true);
tester.invalidate();
SkyKey irrelevant = GraphTester.toSkyKey("irrelevant");
tester.set(irrelevant, new StringValue("irrelevant"));
tester.eval(/*keepGoing=*/
true, irrelevant);
tester.invalidateTransientErrors();
result = tester.eval(/*keepGoing=*/
true, top);
assertTrue(result.toString(), result.hasError());
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method removedNodeComesBackAndOtherInvalidates.
// Tests that a removed and then reinstated node behaves properly when its parent disappears and
// then reappears.
@Test
public void removedNodeComesBackAndOtherInvalidates() throws Exception {
removedNodeComesBack();
SkyKey top = GraphTester.skyKey("top");
SkyKey mid = GraphTester.skyKey("mid");
SkyKey leaf = GraphTester.skyKey("leaf");
// When top is invalidated again,
tester.getOrCreate(top, /*markAsModified=*/
true).removeDependency(leaf).addDependency(mid);
// Then when top is evaluated, its value is as expected.
tester.invalidate();
assertThat(tester.evalAndGet(/*keepGoing=*/
true, top)).isEqualTo(new StringValue("leaf"));
}
Aggregations