use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class ParallelEvaluatorTest method shouldBuildOneTarget.
@Test
public void shouldBuildOneTarget() throws Exception {
graph = new InMemoryGraphImpl();
set("a", "a");
set("b", "b");
SkyKey parentErrorKey = GraphTester.toSkyKey("parent");
SkyKey errorFreeKey = GraphTester.toSkyKey("ab");
SkyKey errorKey = GraphTester.toSkyKey("error");
tester.getOrCreate(parentErrorKey).addDependency(errorKey).addDependency("a").setComputedValue(CONCATENATE);
tester.getOrCreate(errorKey).setHasError(true);
tester.getOrCreate(errorFreeKey).addDependency("a").addDependency("b").setComputedValue(CONCATENATE);
EvaluationResult<StringValue> result = eval(true, parentErrorKey, errorFreeKey);
ErrorInfo error = result.getError(parentErrorKey);
assertThat(error.getRootCauses()).containsExactly(errorKey);
StringValue abValue = result.get(errorFreeKey);
assertEquals("ab", abValue.getValue());
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class ParallelEvaluatorTest method cachedErrorsFromKeepGoingUsedOnNoKeepGoing.
@Test
public void cachedErrorsFromKeepGoingUsedOnNoKeepGoing() throws Exception {
graph = new DeterministicHelper.DeterministicProcessableGraph(new InMemoryGraphImpl());
tester = new GraphTester();
SkyKey errorKey = GraphTester.toSkyKey("error");
SkyKey parent1Key = GraphTester.toSkyKey("parent1");
SkyKey parent2Key = GraphTester.toSkyKey("parent2");
tester.getOrCreate(parent1Key).addDependency(errorKey).setConstantValue(new StringValue("parent1"));
tester.getOrCreate(parent2Key).addDependency(errorKey).setConstantValue(new StringValue("parent2"));
tester.getOrCreate(errorKey).setHasError(true);
EvaluationResult<StringValue> result = eval(/*keepGoing=*/
true, ImmutableList.of(parent1Key));
assertTrue(result.hasError());
assertEquals(errorKey, result.getError().getRootCauseOfException());
result = eval(/*keepGoing=*/
false, ImmutableList.of(parent2Key));
assertTrue(result.hasError());
assertEquals(errorKey, result.getError(parent2Key).getRootCauseOfException());
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method signalValueEnqueued.
@Test
public void signalValueEnqueued() throws Exception {
tester.getOrCreate("top1").setComputedValue(CONCATENATE).addDependency("d1").addDependency("d2");
tester.getOrCreate("top2").setComputedValue(CONCATENATE).addDependency("d3");
tester.getOrCreate("top3");
assertThat(tester.getEnqueuedValues()).isEmpty();
tester.set("d1", new StringValue("1"));
tester.set("d2", new StringValue("2"));
tester.set("d3", new StringValue("3"));
tester.eval(true, "top1");
assertThat(tester.getEnqueuedValues()).containsExactlyElementsIn(Arrays.asList(MemoizingEvaluatorTester.toSkyKeys("top1", "d1", "d2")));
tester.eval(true, "top2");
assertThat(tester.getEnqueuedValues()).containsExactlyElementsIn(Arrays.asList(MemoizingEvaluatorTester.toSkyKeys("top1", "d1", "d2", "top2", "d3")));
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method valueInjectionOverExistingDirtyEntry.
@Test
public void valueInjectionOverExistingDirtyEntry() throws Exception {
SkyKey key = GraphTester.toSkyKey("value");
SkyValue val = new StringValue("val");
tester.getOrCreate(key).setConstantValue(new StringValue("old_val"));
tester.differencer.inject(ImmutableMap.of(key, val));
// Create the value.
tester.eval(/*keepGoing=*/
false, new SkyKey[0]);
tester.differencer.invalidate(ImmutableList.of(key));
// Mark value as dirty.
tester.eval(/*keepGoing=*/
false, new SkyKey[0]);
tester.differencer.inject(ImmutableMap.of(key, val));
// Inject again.
tester.eval(/*keepGoing=*/
false, new SkyKey[0]);
assertEquals(val, tester.evalAndGet("value"));
}
use of com.google.devtools.build.skyframe.GraphTester.StringValue in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method incompleteDirectDepsForDirtyValue.
@Test
public void incompleteDirectDepsForDirtyValue() throws Exception {
initializeTester();
SkyKey topKey = GraphTester.toSkyKey("top");
tester.set(topKey, new StringValue("initial"));
// Put topKey into graph so it will be dirtied on next run.
assertEquals(new StringValue("initial"), tester.evalAndGet(/*keepGoing=*/
false, topKey));
CountDownLatch slowStart = new CountDownLatch(1);
CountDownLatch errorFinish = new CountDownLatch(1);
SkyKey errorKey = GraphTester.toSkyKey("error");
tester.getOrCreate(errorKey).setBuilder(new ChainedFunction(/*notifyStart=*/
null, /*waitToFinish=*/
slowStart, /*notifyFinish=*/
errorFinish, /*waitForException=*/
false, /*value=*/
null, /*deps=*/
ImmutableList.<SkyKey>of()));
SkyKey slowKey = GraphTester.toSkyKey("slow");
tester.getOrCreate(slowKey).setBuilder(new ChainedFunction(/*notifyStart=*/
slowStart, /*waitToFinish=*/
errorFinish, /*notifyFinish=*/
null, /*waitForException=*/
true, new StringValue("slow"), /*deps=*/
ImmutableList.<SkyKey>of()));
SkyKey midKey = GraphTester.toSkyKey("mid");
tester.getOrCreate(midKey).addDependency(slowKey).setComputedValue(COPY);
tester.set(topKey, null);
tester.getOrCreate(topKey).addDependency(midKey).addDependency(errorKey).setComputedValue(CONCATENATE);
tester.invalidate();
// slowKey starts -> errorKey finishes, written to graph -> slowKey finishes & (Visitor aborts)
// -> topKey builds.
EvaluationResult<StringValue> result = tester.eval(/*keepGoing=*/
false, topKey);
assertThat(result.getError().getRootCauses()).containsExactly(errorKey);
// Make sure midKey didn't finish building.
assertEquals(null, tester.getExistingValue(midKey));
// Give slowKey a nice ordinary builder.
tester.getOrCreate(slowKey, /*markAsModified=*/
false).setBuilder(null).setConstantValue(new StringValue("slow"));
// Put midKey into the graph. It won't have a reverse dependence on topKey.
tester.evalAndGet(/*keepGoing=*/
false, midKey);
// topKey should not access midKey as if it were already registered as a dependency.
// We don't invalidate errors, but since topKey wasn't actually written to the graph before, it
// will be rebuilt.
tester.eval(/*keepGoing=*/
true, topKey);
}
Aggregations