This repository was archived by the owner on Sep 3, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
org.scala-refactoring.library/src/test/java/scala/tools/refactoring/tests/util Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ package scala .tools .refactoring .tests .util ;
2+
3+ import org .junit .rules .TestRule ;
4+ import org .junit .runner .Description ;
5+ import org .junit .runners .model .Statement ;
6+
7+ import scala .tools .nsc .util .FailedInterrupt ;
8+
9+ /**
10+ * In case an assertion error is caught and wrapped by another error type (as it
11+ * is the case for exceptions that are thrown on the compiler thread), we need
12+ * to manually unwrap them later, in order to let JUnit "see" them.
13+ */
14+ public final class ExceptionWrapper implements TestRule {
15+
16+ @ Override
17+ public Statement apply (final Statement base , final Description description ) {
18+ return new Statement () {
19+ @ Override
20+ public void evaluate () throws Throwable {
21+ try {
22+ base .evaluate ();
23+ } catch (FailedInterrupt e ) {
24+ // a FailedInterrupt is thrown when an exception occurs on the compiler thread
25+ throw e .getCause ();
26+ }
27+ }
28+ };
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -8,4 +8,7 @@ public abstract class TestRules {
88
99 @ Rule
1010 public final ScalaVersionTestRule rule1 = new ScalaVersionTestRule ();
11+
12+ @ Rule
13+ public final ExceptionWrapper rule2 = new ExceptionWrapper ();
1114}
You can’t perform that action at this time.
0 commit comments