mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
less "caused by" in test exceptions by default (IDEA-CR-16699)
This commit is contained in:
@@ -28,22 +28,6 @@ class EdtTestUtil {
|
||||
@TestOnly @JvmStatic fun runInEdtAndWait(runnable: ThrowableRunnable<Throwable>) {
|
||||
runInEdtAndWait { runnable.run() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #runInEdtAndWait}, but when an unchecked exception happens inside runnable, its just rethrown without being wrapped.
|
||||
* Can be useful to decrease "Caused by" chain for cases when the stack trace of the calling thread is not important or obvious.
|
||||
*/
|
||||
@TestOnly @JvmStatic fun runInEdtAndWaitRethrowing(runnable: ThrowableRunnable<Throwable>) {
|
||||
var exception: Throwable? = null
|
||||
runInEdtAndWait {
|
||||
try {
|
||||
runnable.run()
|
||||
} catch (e: Throwable) {
|
||||
exception = e
|
||||
}
|
||||
}
|
||||
ExceptionUtil.rethrowAllAsUnchecked(exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +35,15 @@ class EdtTestUtil {
|
||||
fun runInEdtAndWait(runnable: () -> Unit) {
|
||||
val application = ApplicationManager.getApplication()
|
||||
if (application is ApplicationImpl) {
|
||||
application.invokeAndWait(runnable)
|
||||
var exception: Throwable? = null
|
||||
application.invokeAndWait {
|
||||
try {
|
||||
runnable()
|
||||
} catch (e: Throwable) {
|
||||
exception = e
|
||||
}
|
||||
}
|
||||
ExceptionUtil.rethrowAllAsUnchecked(exception)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
}
|
||||
|
||||
TestRunnerUtil.replaceIdeEventQueueSafely();
|
||||
EdtTestUtil.runInEdtAndWaitRethrowing(() -> {
|
||||
EdtTestUtil.runInEdtAndWait(() -> {
|
||||
try {
|
||||
ourTestThread = Thread.currentThread();
|
||||
startRunAndTear();
|
||||
|
||||
@@ -414,7 +414,7 @@ public abstract class UsefulTestCase extends TestCase {
|
||||
|
||||
if (runInDispatchThread()) {
|
||||
TestRunnerUtil.replaceIdeEventQueueSafely();
|
||||
EdtTestUtil.runInEdtAndWaitRethrowing(this::defaultRunBare);
|
||||
EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
|
||||
}
|
||||
else {
|
||||
defaultRunBare();
|
||||
|
||||
Reference in New Issue
Block a user