diff options
3 files changed, 13 insertions, 12 deletions
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 27ca052c78..fb9bc023fc 100644 --- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java @@ -88,7 +88,6 @@ public class MemoizingEvaluatorTest { private EventCollector eventCollector; private EventHandler reporter; protected MemoizingEvaluator.EmittedEventState emittedEventState; - @Nullable NotifyingInMemoryGraph graph = null; // Knobs that control the size / duration of larger tests. private static final int TEST_NODE_COUNT = 100; @@ -98,17 +97,15 @@ public class MemoizingEvaluatorTest { @Before public void initializeTester() { initializeTester(null); + initializeReporter(); } @After public void assertNoTrackedErrors() { TrackingAwaiter.INSTANCE.assertNoErrors(); - if (graph != null) { - graph.assertNoExceptions(); - } } - public void initializeTester(@Nullable TrackingInvalidationReceiver customInvalidationReceiver) { + private void initializeTester(@Nullable TrackingInvalidationReceiver customInvalidationReceiver) { emittedEventState = new MemoizingEvaluator.EmittedEventState(); tester = new MemoizingEvaluatorTester(); if (customInvalidationReceiver != null) { @@ -137,14 +134,13 @@ public class MemoizingEvaluatorTest { return true; } - @Before - public void initializeReporter() { + private void initializeReporter() { eventCollector = new EventCollector(); reporter = eventCollector; tester.resetPlayedEvents(); } - protected static SkyKey toSkyKey(String name) { + private static SkyKey toSkyKey(String name) { return SkyKey.create(NODE_TYPE, name); } @@ -3880,7 +3876,6 @@ public class MemoizingEvaluatorTest { } private void setGraphForTesting(NotifyingInMemoryGraph notifyingInMemoryGraph) { - graph = notifyingInMemoryGraph; InMemoryMemoizingEvaluator memoizingEvaluator = (InMemoryMemoizingEvaluator) tester.evaluator; memoizingEvaluator.setGraphForTesting(notifyingInMemoryGraph); } @@ -4074,13 +4069,12 @@ public class MemoizingEvaluatorTest { /** A graph tester that is specific to the memoizing evaluator, with some convenience methods. */ protected class MemoizingEvaluatorTester extends GraphTester { - private RecordingDifferencer differencer; + private RecordingDifferencer differencer = new RecordingDifferencer(); private MemoizingEvaluator evaluator; private BuildDriver driver; private TrackingInvalidationReceiver invalidationReceiver = new TrackingInvalidationReceiver(); public void initialize() { - this.differencer = new RecordingDifferencer(); this.evaluator = getMemoizingEvaluator(getSkyFunctionMap(), differencer, invalidationReceiver); this.driver = getBuildDriver(evaluator); diff --git a/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java b/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java index d553dd1420..ce3ed50831 100644 --- a/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java +++ b/src/test/java/com/google/devtools/build/skyframe/NotifyingInMemoryGraph.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.skyframe; +import com.google.common.base.Joiner; import com.google.common.truth.Truth; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; @@ -76,7 +77,8 @@ public class NotifyingInMemoryGraph extends InMemoryGraph { try { delegate.accept(key, type, order, context); } catch (Exception e) { - unexpectedExceptions.add(e); + TrackingAwaiter.INSTANCE.injectExceptionAndMessage(e, + "In NotifyingInMemoryGraph: " + Joiner.on(", ").join(key, type, order, context)); throw e; } } diff --git a/src/test/java/com/google/devtools/build/skyframe/TrackingAwaiter.java b/src/test/java/com/google/devtools/build/skyframe/TrackingAwaiter.java index 5c0e3565dc..481b9b13e8 100644 --- a/src/test/java/com/google/devtools/build/skyframe/TrackingAwaiter.java +++ b/src/test/java/com/google/devtools/build/skyframe/TrackingAwaiter.java @@ -82,6 +82,11 @@ public class TrackingAwaiter { } } + /** Allow arbitrary errors to be recorded here for later throwing. */ + public void injectExceptionAndMessage(Throwable throwable, String message) { + exceptionsThrown.add(Pair.of(message, throwable)); + } + public void assertNoErrors() { List<Pair<String, Throwable>> thisEvalExceptionsThrown = ImmutableList.copyOf(exceptionsThrown); exceptionsThrown.clear(); |