Skip to content

Commit 41af197

Browse files
committed
Rethrow in TestingThread to show unhandled exceptions
* Fix timeoutExecution() test to show other PolyglotException immediately.
1 parent aaec046 commit 41af197

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/test/java/org/truffleruby/MiscTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import static org.junit.Assert.assertEquals;
1313
import static org.junit.Assert.assertNotEquals;
1414
import static org.junit.Assert.assertTrue;
15-
import static org.junit.Assert.fail;
1615

1716
import org.graalvm.polyglot.Context;
1817
import org.graalvm.polyglot.PolyglotException;
@@ -53,13 +52,17 @@ public void timeoutExecution() throws Throwable {
5352
Thread.sleep(1000);
5453
context.close(true);
5554
} catch (InterruptedException e) {
56-
e.printStackTrace();
57-
fail();
55+
throw new Error(e);
5856
} catch (PolyglotException e) {
59-
assertTrue(e.isCancelled());
57+
if (e.isCancelled()) {
58+
assertTrue(e.isCancelled());
59+
} else {
60+
throw e;
61+
}
6062
}
6163
});
6264

65+
context.eval("ruby", "init = 1");
6366
thread.start();
6467
try {
6568
String maliciousCode = "while true; end";

src/test/java/org/truffleruby/TestingThread.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public TestingThread(Runnable runnable) {
2121
runnable.run();
2222
} catch (Throwable t) {
2323
throwable = t;
24+
throw t;
2425
}
2526
});
2627
}

0 commit comments

Comments
 (0)