From a457b87fe12d732f57a0bf20e8423b6c19cb4830 Mon Sep 17 00:00:00 2001 From: cpeyser Date: Mon, 26 Feb 2018 12:03:24 -0800 Subject: Expose SimpleCycleDetector. Also, allow MemoizingEvaluatorTest to support evaluators that do not store errors alongside values, but which still support error transience. PiperOrigin-RevId: 187058808 --- .../build/skyframe/MemoizingEvaluatorTest.java | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/test/java') 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 b1518fc3b9..7521dd3ea6 100644 --- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java @@ -1207,11 +1207,25 @@ public class MemoizingEvaluatorTest { } } - /** {@link ParallelEvaluator} can be configured to not store errors alongside recovered values. */ + /** + * {@link ParallelEvaluator} can be configured to not store errors alongside recovered values. + * + * @param errorsStoredAlongsideValues true if we expect Skyframe to store the error for the + * cycle in ErrorInfo. If true, supportsTransientExceptions must be true as well. + * @param supportsTransientExceptions true if we expect Skyframe to mark an ErrorInfo as transient + * for certain exception types. + * @param useTransientError true if the test should set the {@link TestFunction} it creates to + * throw a transient error. + */ protected void parentOfCycleAndErrorInternal( - boolean errorsStoredAlongsideValues, boolean useTransientError) + boolean errorsStoredAlongsideValues, + boolean supportsTransientExceptions, + boolean useTransientError) throws Exception { initializeTester(); + if (errorsStoredAlongsideValues) { + Preconditions.checkArgument(supportsTransientExceptions); + } SkyKey cycleKey1 = GraphTester.toSkyKey("cycleKey1"); SkyKey cycleKey2 = GraphTester.toSkyKey("cycleKey2"); SkyKey mid = GraphTester.toSkyKey("mid"); @@ -1247,8 +1261,13 @@ public class MemoizingEvaluatorTest { } else { // When errors are not stored alongside values, transient errors that are recovered from do // not make the parent transient - assertThatErrorInfo(errorInfo).isNotTransient(); - assertThatErrorInfo(errorInfo).hasExceptionThat().isNull(); + if (supportsTransientExceptions) { + assertThatErrorInfo(errorInfo).isTransient(); + assertThatErrorInfo(errorInfo).hasExceptionThat().isNotNull(); + } else { + assertThatErrorInfo(errorInfo).isNotTransient(); + assertThatErrorInfo(errorInfo).hasExceptionThat().isNull(); + } } if (cyclesDetected()) { assertThatErrorInfo(errorInfo) @@ -1267,7 +1286,9 @@ public class MemoizingEvaluatorTest { @Test public void parentOfCycleAndError() throws Exception { parentOfCycleAndErrorInternal( - /*errorsStoredAlongsideValues=*/ true, /*useTransientError=*/ true); + /*errorsStoredAlongsideValues=*/ true, + /*supportsTransientExceptions=*/ true, + /*useTransientError=*/ true); } /** -- cgit v1.2.3