mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] Handle exceptions in junit5 fixtures
GitOrigin-RevId: 891f6f19b2563f64547e81d75f3878e4c1a0c389
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b00f652930
commit
4b66658d03
@@ -40,10 +40,7 @@ internal class TestFixtureExtension : BeforeAllCallback,
|
||||
val fixture = field.get(testInstance) as TestFixtureImpl<*>
|
||||
pendingFixtures.add(fixture.init(testScope, context.uniqueId))
|
||||
}
|
||||
@Suppress("SSBasedInspection")
|
||||
runBlocking {
|
||||
pendingFixtures.awaitAll()
|
||||
}
|
||||
awaitFixtureInitialization(testScope, pendingFixtures)
|
||||
context.getStore(ExtensionContext.Namespace.GLOBAL).put("TestFixtureExtension", testScope)
|
||||
}
|
||||
|
||||
@@ -63,3 +60,21 @@ internal class TestFixtureExtension : BeforeAllCallback,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun awaitFixtureInitialization(cleanupScope: CoroutineScope, pendingFixtures: List<Deferred<*>>) {
|
||||
@Suppress("SSBasedInspection")
|
||||
runBlocking {
|
||||
try {
|
||||
pendingFixtures.awaitAll()
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
try {
|
||||
cleanupScope.coroutineContext.job.cancelAndJoin()
|
||||
}
|
||||
catch (exceptionDuringCleanup: Throwable) {
|
||||
e.addSuppressed(Throwable("Exception during cleanup of test fixture", exceptionDuringCleanup))
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user