aboutsummaryrefslogtreecommitdiff
path: root/integration-tests/gradle/src/main/kotlin/org
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-02 14:18:51 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-06 15:34:57 +0200
commita573641a70a626983c1d63965e377ea0be274f41 (patch)
treefa242cb03627437c6a40a38900d894c97a6436c0 /integration-tests/gradle/src/main/kotlin/org
parentb594564969ec4d93d59e4850a63f0fbf8f68cf7a (diff)
downloaddokka-a573641a70a626983c1d63965e377ea0be274f41.tar.gz
dokka-a573641a70a626983c1d63965e377ea0be274f41.tar.bz2
dokka-a573641a70a626983c1d63965e377ea0be274f41.zip
Implement AndroidGradleIntegrationTest
Diffstat (limited to 'integration-tests/gradle/src/main/kotlin/org')
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractDefaultVersionsGradleIntegrationTest.kt84
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt30
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt38
-rw-r--r--integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt29
4 files changed, 55 insertions, 126 deletions
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractDefaultVersionsGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractDefaultVersionsGradleIntegrationTest.kt
deleted file mode 100644
index 80737129..00000000
--- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractDefaultVersionsGradleIntegrationTest.kt
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.jetbrains.dokka.it.gradle
-
-import org.gradle.util.GradleVersion
-import org.junit.Assume
-import org.junit.Test
-
-abstract class AbstractDefaultVersionsGradleIntegrationTest(
- private val minGradleVersion: GradleVersion? = null,
- private val maxGradleVersion: GradleVersion? = null
-) : AbstractGradleIntegrationTest() {
-
- protected abstract fun execute(versions: BuildVersions)
-
- private fun executeIfRequirementsAreMet(versions: BuildVersions) {
- if (minGradleVersion != null) {
- Assume.assumeTrue(versions.gradleVersion >= minGradleVersion)
- }
- if (maxGradleVersion != null) {
- Assume.assumeTrue(versions.gradleVersion <= maxGradleVersion)
- }
-
- execute(versions )
- }
-
- @Test
- open fun `gradle 5_6_4 kotlin 1_3_72`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "5.6.4",
- kotlinVersion = "1.3.72"
- )
- )
- }
-
- @Test
- open fun `gradle 5_6_4 kotlin 1_3_30`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "5.6.4",
- kotlinVersion = "1.3.30"
- )
- )
- }
-
- @Test
- open fun `gradle 5_6_4 kotlin 1_4_M2_eap_70`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "5.6.4",
- kotlinVersion = "1.4-M2-eap-70"
- )
- )
- }
-
- @Test
- open fun `gradle 6_1_1 kotlin 1_3_72`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "6.1.1",
- kotlinVersion = "1.3.72"
- )
- )
- }
-
- @Test
- open fun `gradle 6_5_1 kotlin 1_4_M2_eap_70`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "6.5.1",
- kotlinVersion = "1.4-M2-eap-70"
- )
- )
- }
-
- @Test
- open fun `gradle 6_5_1 kotlin 1_3_72`() {
- executeIfRequirementsAreMet(
- BuildVersions(
- gradleVersion = "6.5.1",
- kotlinVersion = "1.3.72"
- )
- )
- }
-}
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 e6b6b0eb..bb2d0cc6 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,21 +1,26 @@
package org.jetbrains.dokka.it.gradle
import org.gradle.testkit.runner.GradleRunner
+import org.gradle.testkit.runner.internal.DefaultGradleRunner
import org.junit.Rule
import org.junit.rules.TemporaryFolder
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
import java.io.File
import kotlin.test.BeforeTest
+import kotlin.test.Test
import kotlin.test.assertFalse
+@RunWith(Parameterized::class)
abstract class AbstractGradleIntegrationTest {
+ abstract val versions: BuildVersions
+
@get:Rule
val temporaryTestFolder = TemporaryFolder()
val projectDir get() = File(temporaryTestFolder.root, "project")
- val projectPath get() = projectDir.toPath()
-
@BeforeTest
fun copyTemplates() {
File("projects").listFiles().orEmpty()
@@ -25,19 +30,24 @@ abstract class AbstractGradleIntegrationTest {
}
fun createGradleRunner(
- buildVersions: BuildVersions, arguments: Array<String>
+ vararg arguments: String
): GradleRunner {
return GradleRunner.create()
.withProjectDir(projectDir)
- .withGradleVersion(buildVersions.gradleVersion.version)
+ .withGradleVersion(versions.gradleVersion.version)
.forwardOutput()
+ .withTestKitDir(File("build", "gradle-test-kit").absoluteFile)
.withArguments(
- "-Pkotlin_version=${buildVersions.kotlinVersion}",
- "-Pdokka_it_kotlin_version=${buildVersions.kotlinVersion}",
- * arguments
- )
- .withDebug(true)
-
+ listOfNotNull(
+ "-Pkotlin_version=${versions.kotlinVersion}",
+ "-Pdokka_it_kotlin_version=${versions.kotlinVersion}",
+ versions.androidGradlePluginVersion?.let { androidVersion ->
+ "-Pdokka_it_android_gradle_plugin_version=$androidVersion"
+ },
+ * arguments
+ )
+ ).run { this as DefaultGradleRunner }
+ .withJvmArguments("-Xmx4G", "-XX:MaxMetaspaceSize=512M")
}
fun File.allDescendentsWithExtension(extension: String): Sequence<File> {
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt
index 2fdd0368..84a7f1e8 100644
--- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt
+++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/BuildVersions.kt
@@ -4,13 +4,45 @@ import org.gradle.util.GradleVersion
data class BuildVersions(
val gradleVersion: GradleVersion,
- val kotlinVersion: String
+ val kotlinVersion: String,
+ val androidGradlePluginVersion: String? = null,
) {
constructor(
gradleVersion: String,
- kotlinVersion: String
+ kotlinVersion: String,
+ androidGradlePluginVersion: String? = null
) : this(
gradleVersion = GradleVersion.version(gradleVersion),
- kotlinVersion = kotlinVersion
+ kotlinVersion = kotlinVersion,
+ androidGradlePluginVersion = androidGradlePluginVersion
)
+
+ override fun toString(): String {
+ return buildString {
+ append("Gradle ${gradleVersion.version}, Kotlin $kotlinVersion")
+ if (androidGradlePluginVersion != null) {
+ append(", Android $androidGradlePluginVersion")
+ }
+ }
+ }
+
+ companion object {
+ fun permutations(
+ gradleVersions: List<String>,
+ kotlinVersions: List<String>,
+ androidGradlePluginVersions: List<String?> = listOf(null)
+ ): List<BuildVersions> {
+ return gradleVersions.distinct().flatMap { gradleVersion ->
+ kotlinVersions.distinct().flatMap { kotlinVersion ->
+ androidGradlePluginVersions.distinct().map { androidVersion ->
+ BuildVersions(
+ gradleVersion = gradleVersion,
+ kotlinVersion = kotlinVersion,
+ androidGradlePluginVersion = androidVersion
+ )
+ }
+ }
+ }
+ }
+ }
}
diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt
deleted file mode 100644
index 2516b151..00000000
--- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/utils.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.jetbrains.dokka.it.gradle
-
-import java.io.IOException
-import java.nio.file.*
-import java.nio.file.attribute.BasicFileAttributes
-
-fun Path.copy(to: Path) {
- Files.walkFileTree(this, CopyFileVisitor(this, to))
-}
-
-class CopyFileVisitor(private var sourcePath: Path, private val targetPath: Path) : SimpleFileVisitor<Path>() {
- @Throws(IOException::class)
- override fun preVisitDirectory(
- dir: Path,
- attrs: BasicFileAttributes
- ): FileVisitResult {
- Files.createDirectories(targetPath.resolve(sourcePath.relativize(dir)))
- return FileVisitResult.CONTINUE
- }
-
- @Throws(IOException::class)
- override fun visitFile(
- file: Path,
- attrs: BasicFileAttributes
- ): FileVisitResult {
- Files.copy(file, targetPath.resolve(sourcePath.relativize(file)), StandardCopyOption.REPLACE_EXISTING)
- return FileVisitResult.CONTINUE
- }
-}