use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method absentParent.
@Test
public void absentParent() throws Exception {
initializeTester();
SkyKey errorKey = GraphTester.toSkyKey("my_error_value");
tester.set(errorKey, new StringValue("biding time"));
SkyKey absentParentKey = GraphTester.toSkyKey("absentParent");
tester.getOrCreate(absentParentKey).addDependency(errorKey).setComputedValue(CONCATENATE);
assertEquals(new StringValue("biding time"), tester.evalAndGet(/*keepGoing=*/
false, absentParentKey));
tester.getOrCreate(errorKey, /*markAsModified=*/
true).setHasError(true);
SkyKey newParent = GraphTester.toSkyKey("newParent");
tester.getOrCreate(newParent).addDependency(errorKey).setComputedValue(CONCATENATE);
tester.invalidate();
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
false, newParent);
ErrorInfo error = result.getError(newParent);
assertThat(error.getRootCauses()).containsExactly(errorKey);
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method incrementalDiamondDependency.
@Test
public void incrementalDiamondDependency() throws Exception {
setupDiamondDependency();
tester.set("d", new StringValue("me"));
tester.evalAndGet("a");
tester.set("d", new StringValue("other"));
tester.invalidate();
StringValue value = (StringValue) tester.evalAndGet("a");
assertEquals("otherother", value.getValue());
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method breakWithErrorDep.
@Test
public void breakWithErrorDep() throws Exception {
SkyKey errorKey = GraphTester.toSkyKey("my_error_value");
tester.getOrCreate(errorKey).setHasError(true);
tester.set("after", new StringValue("after"));
SkyKey parentKey = GraphTester.toSkyKey("parent");
tester.getOrCreate(parentKey).addErrorDependency(errorKey, new StringValue("recovered")).setComputedValue(CONCATENATE).addDependency("after");
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
false, parentKey);
assertThat(result.keyNames()).isEmpty();
Map.Entry<SkyKey, ErrorInfo> error = Iterables.getOnlyElement(result.errorMap().entrySet());
assertEquals(parentKey, error.getKey());
assertThat(error.getValue().getRootCauses()).containsExactly(errorKey);
result = tester.eval(/*keepGoing=*/
true, parentKey);
assertThat(result.errorMap()).isEmpty();
assertEquals("recoveredafter", result.get(parentKey).getValue());
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method changePruning.
@Test
public void changePruning() throws Exception {
initializeTester();
SkyKey leaf = GraphTester.toSkyKey("leaf");
SkyKey mid = GraphTester.toSkyKey("mid");
SkyKey top = GraphTester.toSkyKey("top");
tester.getOrCreate(top).addDependency(mid).setComputedValue(COPY);
tester.getOrCreate(mid).addDependency(leaf).setComputedValue(COPY);
tester.set(leaf, new StringValue("leafy"));
StringValue topValue = (StringValue) tester.evalAndGet("top");
assertEquals("leafy", topValue.getValue());
// Mark leaf changed, but don't actually change it.
tester.getOrCreate(leaf, /*markAsModified=*/
true);
// mid will give an error if re-evaluated, but it shouldn't be because it is not marked changed,
// and its dirty child will evaluate to the same element.
tester.getOrCreate(mid, /*markAsModified=*/
false).setHasError(true);
tester.invalidate();
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
false, top);
assertFalse(result.hasError());
topValue = result.get(top);
assertEquals("leafy", topValue.getValue());
assertThat(tester.getDirtyKeys()).isEmpty();
assertThat(tester.getDeletedKeys()).isEmpty();
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method noKeepGoingAfterKeepGoingCycle.
@Test
public void noKeepGoingAfterKeepGoingCycle() throws Exception {
initializeTester();
SkyKey aKey = GraphTester.toSkyKey("a");
SkyKey bKey = GraphTester.toSkyKey("b");
SkyKey topKey = GraphTester.toSkyKey("top");
SkyKey midKey = GraphTester.toSkyKey("mid");
SkyKey goodKey = GraphTester.toSkyKey("good");
StringValue goodValue = new StringValue("good");
tester.set(goodKey, goodValue);
tester.getOrCreate(topKey).addDependency(midKey);
tester.getOrCreate(midKey).addDependency(aKey);
tester.getOrCreate(aKey).addDependency(bKey);
tester.getOrCreate(bKey).addDependency(aKey);
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
true, topKey, goodKey);
assertEquals(goodValue, result.get(goodKey));
assertEquals(null, result.get(topKey));
ErrorInfo errorInfo = result.getError(topKey);
CycleInfo cycleInfo = Iterables.getOnlyElement(errorInfo.getCycleInfo());
if (cyclesDetected()) {
assertThat(cycleInfo.getCycle()).containsExactly(aKey, bKey).inOrder();
assertThat(cycleInfo.getPathToCycle()).containsExactly(topKey, midKey).inOrder();
}
tester.invalidate();
result = tester.eval(/*keepGoing=*/
false, topKey, goodKey);
assertEquals(null, result.get(topKey));
errorInfo = result.getError(topKey);
cycleInfo = Iterables.getOnlyElement(errorInfo.getCycleInfo());
if (cyclesDetected()) {
assertThat(cycleInfo.getCycle()).containsExactly(aKey, bKey).inOrder();
assertThat(cycleInfo.getPathToCycle()).containsExactly(topKey, midKey).inOrder();
}
}
Aggregations