use of com.google.devtools.build.skyframe.SkyFunctionException.ReifiedSkyFunctionException in project bazel by bazelbuild.
the class InMemoryNodeEntryTest method errorValue.
@Test
public void errorValue() throws InterruptedException {
NodeEntry entry = new InMemoryNodeEntry();
// Start evaluation.
entry.addReverseDepAndCheckIfDone(null);
ReifiedSkyFunctionException exception = new ReifiedSkyFunctionException(new GenericFunctionException(new SomeErrorException("oops"), Transience.PERSISTENT), key("cause"));
ErrorInfo errorInfo = ErrorInfo.fromException(exception, false);
assertThat(setValue(entry, /*value=*/
null, errorInfo, /*graphVersion=*/
0L)).isEmpty();
assertTrue(entry.isDone());
assertNull(entry.getValue());
assertEquals(errorInfo, entry.getErrorInfo());
}
use of com.google.devtools.build.skyframe.SkyFunctionException.ReifiedSkyFunctionException in project bazel by bazelbuild.
the class ErrorInfoTest method runTestFromException.
private void runTestFromException(boolean isDirectlyTransient, boolean isTransitivelyTransient) {
Exception exception = new IOException("ehhhhh");
SkyKey causeOfException = SkyKey.create(SkyFunctionName.create("CAUSE"), 1234);
DummySkyFunctionException dummyException = new DummySkyFunctionException(exception, isDirectlyTransient, /*isCatastrophic=*/
false);
ErrorInfo errorInfo = ErrorInfo.fromException(new ReifiedSkyFunctionException(dummyException, causeOfException), isTransitivelyTransient);
assertThat(errorInfo.getRootCauses()).containsExactly(causeOfException);
assertThat(errorInfo.getException()).isSameAs(exception);
assertThat(errorInfo.getRootCauseOfException()).isSameAs(causeOfException);
assertThat(errorInfo.getCycleInfo()).isEmpty();
assertThat(errorInfo.isTransient()).isEqualTo(isDirectlyTransient || isTransitivelyTransient);
assertThat(errorInfo.isCatastrophic()).isFalse();
}
use of com.google.devtools.build.skyframe.SkyFunctionException.ReifiedSkyFunctionException in project bazel by bazelbuild.
the class InMemoryNodeEntryTest method errorInfoCannotBePruned.
@Test
public void errorInfoCannotBePruned() throws InterruptedException {
NodeEntry entry = new InMemoryNodeEntry();
// Start evaluation.
entry.addReverseDepAndCheckIfDone(null);
SkyKey dep = key("dep");
addTemporaryDirectDep(entry, dep);
entry.signalDep();
ReifiedSkyFunctionException exception = new ReifiedSkyFunctionException(new GenericFunctionException(new SomeErrorException("oops"), Transience.PERSISTENT), key("cause"));
ErrorInfo errorInfo = ErrorInfo.fromException(exception, false);
setValue(entry, /*value=*/
null, errorInfo, /*graphVersion=*/
0L);
entry.markDirty(/*isChanged=*/
false);
// Restart evaluation.
entry.addReverseDepAndCheckIfDone(null);
assertEquals(NodeEntry.DirtyState.CHECK_DEPENDENCIES, entry.getDirtyState());
assertThat(entry.getNextDirtyDirectDeps()).containsExactly(dep);
addTemporaryDirectDep(entry, dep);
entry.signalDep(IntVersion.of(1L));
assertEquals(NodeEntry.DirtyState.NEEDS_REBUILDING, entry.getDirtyState());
assertThatNodeEntry(entry).hasTemporaryDirectDepsThat().containsExactly(dep);
entry.markRebuilding();
setValue(entry, /*value=*/
null, errorInfo, /*graphVersion=*/
1L);
assertTrue(entry.isDone());
// ErrorInfo is treated as a NotComparableSkyValue, so it is not pruned.
assertEquals(IntVersion.of(1L), entry.getVersion());
}
use of com.google.devtools.build.skyframe.SkyFunctionException.ReifiedSkyFunctionException in project bazel by bazelbuild.
the class InMemoryNodeEntryTest method maintainDependencyGroupAfterRemoval.
@Test
public void maintainDependencyGroupAfterRemoval() throws InterruptedException {
NodeEntry entry = new InMemoryNodeEntry();
// Start evaluation.
entry.addReverseDepAndCheckIfDone(null);
SkyKey dep = key("dep");
SkyKey dep2 = key("dep2");
SkyKey dep3 = key("dep3");
SkyKey dep4 = key("dep4");
SkyKey dep5 = key("dep5");
addTemporaryDirectDeps(entry, dep, dep2, dep3);
addTemporaryDirectDep(entry, dep4);
addTemporaryDirectDep(entry, dep5);
entry.signalDep();
entry.signalDep();
// Oops! Evaluation terminated with an error, but we're going to set this entry's value anyway.
entry.removeUnfinishedDeps(ImmutableSet.of(dep2, dep3, dep5));
ReifiedSkyFunctionException exception = new ReifiedSkyFunctionException(new GenericFunctionException(new SomeErrorException("oops"), Transience.PERSISTENT), key("key"));
setValue(entry, null, ErrorInfo.fromException(exception, false), 0L);
entry.markDirty(/*isChanged=*/
false);
// Restart evaluation.
entry.addReverseDepAndCheckIfDone(null);
assertEquals(NodeEntry.DirtyState.CHECK_DEPENDENCIES, entry.getDirtyState());
assertThat(entry.getNextDirtyDirectDeps()).containsExactly(dep);
addTemporaryDirectDep(entry, dep);
entry.signalDep(IntVersion.of(0L));
assertEquals(NodeEntry.DirtyState.CHECK_DEPENDENCIES, entry.getDirtyState());
assertThat(entry.getNextDirtyDirectDeps()).containsExactly(dep4);
}
use of com.google.devtools.build.skyframe.SkyFunctionException.ReifiedSkyFunctionException in project bazel by bazelbuild.
the class ErrorInfo method fromException.
/** Create an ErrorInfo from a {@link ReifiedSkyFunctionException}. */
public static ErrorInfo fromException(ReifiedSkyFunctionException skyFunctionException, boolean isTransitivelyTransient) {
SkyKey rootCauseSkyKey = skyFunctionException.getRootCauseSkyKey();
Exception rootCauseException = skyFunctionException.getCause();
return new ErrorInfo(NestedSetBuilder.create(Order.STABLE_ORDER, rootCauseSkyKey), Preconditions.checkNotNull(rootCauseException, "Cause null %s", rootCauseException), rootCauseSkyKey, /*cycles=*/
ImmutableList.<CycleInfo>of(), isTransitivelyTransient || skyFunctionException.isTransient(), skyFunctionException.isCatastrophic());
}
Aggregations