Skip to content

Commit b53bf4b

Browse files
sellmairSpace Team
authored and
Space Team
committed
[Gradle][Minor] runLifecycleAwareTest: Prefer re-throwing AssertionError
^KT-58255 Verification Pending
1 parent 0ab0788 commit b53bf4b

File tree

1 file changed

+10
-1
lines changed
  • libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/util

1 file changed

+10
-1
lines changed

libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/util/lifecycleUtils.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ package org.jetbrains.kotlin.gradle.util
88
import org.gradle.api.Project
99
import org.gradle.api.internal.project.ProjectInternal
1010
import org.jetbrains.kotlin.gradle.plugin.kotlinPluginLifecycle
11+
import org.jetbrains.kotlin.tooling.core.withLinearClosure
12+
import java.lang.AssertionError
1113

1214
fun Project.runLifecycleAwareTest(block: suspend Project.() -> Unit) {
1315
kotlinPluginLifecycle.launch { block() }
14-
(this as ProjectInternal).evaluate()
16+
try {
17+
(this as ProjectInternal).evaluate()
18+
} catch (t: Throwable) {
19+
/* Prefer throwing AssertionError directly, if possible */
20+
val allCauses = t.withLinearClosure { it.cause }
21+
allCauses.find { it is AssertionError }?.let { throw it }
22+
throw t
23+
}
1524
}

0 commit comments

Comments
 (0)