From 7bc909a0d09627ab2fd4b595fe886809cb9ba1b6 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 16 Sep 2014 13:42:07 +0400 Subject: [PATCH] fail test in case of exception --- .../openapi/progress/util/ProgressIndicatorTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/progress/util/ProgressIndicatorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/progress/util/ProgressIndicatorTest.java index 4014541202fb..70a6defb322f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/progress/util/ProgressIndicatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/progress/util/ProgressIndicatorTest.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.List; +import java.util.Random; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; @@ -138,8 +139,8 @@ public class ProgressIndicatorTest extends LightPlatformTestCase { assertTrue(indicator.isCanceled()); } - public void testThereIsNoDelayBetweenIndicatorCancelAndProgressManagerCheckCanceled() { - for (int i=0; i<1000;i++) { + public void testThereIsNoDelayBetweenIndicatorCancelAndProgressManagerCheckCanceled() throws Throwable { + for (int i=0; i<100;i++) { final ProgressIndicatorBase indicator = new ProgressIndicatorBase(); List threads = ContainerUtil.map(Collections.nCopies(10, ""), new Function() { @Override @@ -151,13 +152,16 @@ public class ProgressIndicatorTest extends LightPlatformTestCase { @Override public void run() { try { - boolean canceled = indicator.isCanceled(); + Thread.sleep(new Random().nextInt(100)); indicator.cancel(); ProgressManager.checkCanceled(); fail("checkCanceled() must know about canceled indicator even from different thread"); } catch (ProcessCanceledException ignored) { } + catch (Throwable e) { + exception = e; + } } }, indicator); } @@ -177,7 +181,7 @@ public class ProgressIndicatorTest extends LightPlatformTestCase { } }); } - + if (exception != null) throw exception; } private volatile boolean checkCanceledCalled;