[Gradle][Minor] runLifecycleAwareTest: Prefer re-throwing AssertionError
^KT-58255 Verification Pending
This commit is contained in:
committed by
Space Team
parent
0ab0788763
commit
b53bf4b148
+10
-1
@@ -8,8 +8,17 @@ package org.jetbrains.kotlin.gradle.util
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.internal.project.ProjectInternal
|
import org.gradle.api.internal.project.ProjectInternal
|
||||||
import org.jetbrains.kotlin.gradle.plugin.kotlinPluginLifecycle
|
import org.jetbrains.kotlin.gradle.plugin.kotlinPluginLifecycle
|
||||||
|
import org.jetbrains.kotlin.tooling.core.withLinearClosure
|
||||||
|
import java.lang.AssertionError
|
||||||
|
|
||||||
fun Project.runLifecycleAwareTest(block: suspend Project.() -> Unit) {
|
fun Project.runLifecycleAwareTest(block: suspend Project.() -> Unit) {
|
||||||
kotlinPluginLifecycle.launch { block() }
|
kotlinPluginLifecycle.launch { block() }
|
||||||
(this as ProjectInternal).evaluate()
|
try {
|
||||||
|
(this as ProjectInternal).evaluate()
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
/* Prefer throwing AssertionError directly, if possible */
|
||||||
|
val allCauses = t.withLinearClosure { it.cause }
|
||||||
|
allCauses.find { it is AssertionError }?.let { throw it }
|
||||||
|
throw t
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user