aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/gradle/src/main/kotlin/org
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-14 14:55:46 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-15 08:07:48 +0200
commit2c9fe4c22e13f4d84f4085563715162fcdf2ec85 (patch)
tree09a940fc57be5eb93761fa199c00694359f8686c /integration-tests/gradle/src/main/kotlin/org
parent2aa1acac46630c617ddf934556c85c192e2ba03a (diff)
downloaddokka-2c9fe4c22e13f4d84f4085563715162fcdf2ec85.tar.gz
dokka-2c9fe4c22e13f4d84f4085563715162fcdf2ec85.tar.bz2
dokka-2c9fe4c22e13f4d84f4085563715162fcdf2ec85.zip
Implement GradleRunner.buildRelaxed API
Diffstat (limited to 'integration-tests/gradle/src/main/kotlin/org')
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
index 5b3e3250..f852dc8b 100644
--- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
+++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
@@ -1,8 +1,13 @@
package org.jetbrains.dokka.it.gradle
+import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.internal.DefaultGradleRunner
+import org.gradle.tooling.GradleConnectionException
import org.jetbrains.dokka.it.AbstractIntegrationTest
+import org.junit.Assume
+import org.junit.Assume.assumeFalse
+import org.junit.AssumptionViolatedException
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
@@ -41,4 +46,29 @@ abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest() {
).run { this as DefaultGradleRunner }
.withJvmArguments("-Xmx4G", "-XX:MaxMetaspaceSize=2G")
}
+
+ fun GradleRunner.buildRelaxed(): BuildResult {
+ return try {
+ build()
+ } catch (e: Throwable) {
+ val gradleConnectionException = e.withAllCauses().find { it is GradleConnectionException }
+ if (gradleConnectionException != null) {
+ gradleConnectionException.printStackTrace()
+ throw AssumptionViolatedException("Assumed Gradle connection", gradleConnectionException)
+
+ }
+ throw e
+ }
+ }
+}
+
+private fun Throwable.withAllCauses(): Sequence<Throwable> {
+ val root = this
+ return sequence {
+ yield(root)
+ val cause = root.cause
+ if (cause != null && cause != root) {
+ yieldAll(cause.withAllCauses())
+ }
+ }
}