aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-09-02 17:56:08 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-09-02 21:08:04 +0000
commita67bb8b2ad5506c2a3c7c4476d9878d4f916656d (patch)
treeb01d6c99919f3dc5882115da32e477384098c52f /src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
parent2e003439cecfe87e318037f19ffd5e3761724948 (diff)
Use TrackingAwaiter properly to track lost exceptions. Using the static method wasn't guaranteed to catch all bugs. Also convert to a singleton since there's no reason to have multiple instances.
-- MOS_MIGRATED_REVID=102158719
Diffstat (limited to 'src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java b/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
index c0d349d025..aa9b036154 100644
--- a/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/EagerInvalidatorTest.java
@@ -40,6 +40,7 @@ import com.google.devtools.build.skyframe.InvalidatingNodeVisitor.DirtyingNodeVi
import com.google.devtools.build.skyframe.InvalidatingNodeVisitor.InvalidationState;
import com.google.devtools.build.skyframe.InvalidatingNodeVisitor.InvalidationType;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
@@ -69,6 +70,11 @@ public class EagerInvalidatorTest {
private IntVersion graphVersion = new IntVersion(0);
+ @After
+ public void assertNoTrackedErrors() {
+ TrackingAwaiter.INSTANCE.assertNoErrors();
+ }
+
// The following three methods should be abstract, but junit4 does not allow us to run inner
// classes in an abstract outer class. Thus, we provide implementations. These methods will never
// be run because only the inner classes, annotated with @RunWith, will actually be executed.
@@ -466,37 +472,34 @@ public class EagerInvalidatorTest {
}
int countDownStart = validValuesToDo > 0 ? random.nextInt(validValuesToDo) : 0;
final CountDownLatch countDownToInterrupt = new CountDownLatch(countDownStart);
- final EvaluationProgressReceiver receiver = new EvaluationProgressReceiver() {
- @Override
- public void invalidated(SkyKey skyKey, InvalidationState state) {
- countDownToInterrupt.countDown();
- if (countDownToInterrupt.getCount() == 0) {
- mainThread.interrupt();
- try {
- // Wait for the main thread to be interrupted uninterruptibly, because the main thread
- // is going to interrupt us, and we don't want to get into an interrupt fight. Only
- // if we get interrupted without the main thread also being interrupted will this
- // throw an InterruptedException.
- TrackingAwaiter.waitAndMaybeThrowInterrupt(
- visitor.get().getInterruptionLatchForTestingOnly(),
- "Main thread was not interrupted");
- } catch (InterruptedException e) {
- throw new IllegalStateException(e);
+ final EvaluationProgressReceiver receiver =
+ new EvaluationProgressReceiver() {
+ @Override
+ public void invalidated(SkyKey skyKey, InvalidationState state) {
+ countDownToInterrupt.countDown();
+ if (countDownToInterrupt.getCount() == 0) {
+ mainThread.interrupt();
+ // Wait for the main thread to be interrupted uninterruptibly, because the main
+ // thread is going to interrupt us, and we don't want to get into an interrupt
+ // fight. Only if we get interrupted without the main thread also being interrupted
+ // will this throw an InterruptedException.
+ TrackingAwaiter.INSTANCE.awaitLatchAndTrackExceptions(
+ visitor.get().getInterruptionLatchForTestingOnly(),
+ "Main thread was not interrupted");
+ }
}
- }
- }
- @Override
- public void enqueueing(SkyKey skyKey) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public void enqueueing(SkyKey skyKey) {
+ throw new UnsupportedOperationException();
+ }
- @Override
- public void evaluated(SkyKey skyKey, Supplier<SkyValue> skyValueSupplier,
- EvaluationState state) {
- throw new UnsupportedOperationException();
- }
- };
+ @Override
+ public void evaluated(
+ SkyKey skyKey, Supplier<SkyValue> skyValueSupplier, EvaluationState state) {
+ throw new UnsupportedOperationException();
+ }
+ };
try {
invalidate(graph, receiver,
Sets.newHashSet(