diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-02 14:18:51 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-07-06 15:34:57 +0200 |
commit | a573641a70a626983c1d63965e377ea0be274f41 (patch) | |
tree | fa242cb03627437c6a40a38900d894c97a6436c0 /integration-tests/gradle/src | |
parent | b594564969ec4d93d59e4850a63f0fbf8f68cf7a (diff) | |
download | dokka-a573641a70a626983c1d63965e377ea0be274f41.tar.gz dokka-a573641a70a626983c1d63965e377ea0be274f41.tar.bz2 dokka-a573641a70a626983c1d63965e377ea0be274f41.zip |
Implement AndroidGradleIntegrationTest
Diffstat (limited to 'integration-tests/gradle/src')
7 files changed, 154 insertions, 145 deletions
diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt new file mode 100644 index 00000000..93d84e1f --- /dev/null +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt @@ -0,0 +1,69 @@ +package org.jetbrains.dokka.it.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.Assume +import org.junit.runners.Parameterized.Parameters +import java.io.File +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotNull + +class Android0GradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { + + companion object { + @get:JvmStatic + @get:Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.5.1", "5.6.4"), + kotlinVersions = listOf("1.3.72", "1.4-M2-eap-70"), + androidGradlePluginVersions = listOf("3.5.3", "3.6.3") + ) + BuildVersions.permutations( + gradleVersions = listOf("6.5.1","6.1.1"), + kotlinVersions = listOf("1.3.72", "1.4-M2-eap-70"), + androidGradlePluginVersions = listOf("4.0.0") + ) + BuildVersions.permutations( + gradleVersions = listOf("6.5.1"), + kotlinVersions = listOf("1.3.72", "1.4-M2-eap-70"), + androidGradlePluginVersions = listOf("4.1.0-beta02") + ) + } + + @BeforeTest + fun assumeAndroidInstallation() { + val isCI = System.getenv("CI") != null + if (isCI) { + return + } + + val androidSdkRoot = System.getenv("ANDROID_SDK_ROOT") + val androidHome = System.getenv("ANDROID_HOME") + + val isAndroidSdkInstalled = androidSdkRoot != null || androidHome != null + + Assume.assumeTrue( + "Missing ANDROID_SDK_ROOT", + isAndroidSdkInstalled + ) + } + + @BeforeTest + fun prepareProjectFiles() { + val templateProjectDir = File("projects", "it-android-0") + + templateProjectDir.listFiles().orEmpty() + .filter { it.isFile } + .filterNot { it.name == "local.properties" } + .filterNot { it.name.startsWith("gradlew") } + .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) } + + File(templateProjectDir, "src").copyRecursively(File(projectDir, "src")) + } + + @Test + fun execute() { + val result = createGradleRunner("dokka", "--stacktrace").build() + assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokka")).outcome) + } + +} diff --git a/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt index b4d9e82c..c3adce4f 100644 --- a/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt @@ -1,10 +1,21 @@ package org.jetbrains.dokka.it.gradle import org.gradle.testkit.runner.TaskOutcome +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters import java.io.File import kotlin.test.* -class BasicGradleIntegrationTest : AbstractDefaultVersionsGradleIntegrationTest() { +class BasicGradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { + + companion object { + @get:JvmStatic + @get:Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.5.1", "6.4.1", "6.3", "6.2.2", "6.1.1", "6.0", "5.6.4"), + kotlinVersions = listOf("1.3.30", "1.3.72", "1.4-M2-eap-70") + ) + } @BeforeTest fun prepareProjectFiles() { @@ -17,11 +28,9 @@ class BasicGradleIntegrationTest : AbstractDefaultVersionsGradleIntegrationTest( File(templateProjectDir, "src").copyRecursively(File(projectDir, "src")) } - override fun execute(versions: BuildVersions) { - val result = createGradleRunner( - buildVersions = versions, - arguments = arrayOf("dokka", "--stacktrace") - ).build() + @Test + fun execute() { + val result = createGradleRunner("dokka", "--stacktrace").build() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokka")).outcome) val dokkaOutputDir = File(projectDir, "build/dokka") diff --git a/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt index a0f6be24..b54eecb1 100644 --- a/integration-tests/gradle/src/test/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt @@ -2,15 +2,20 @@ package org.jetbrains.dokka.it.gradle import org.gradle.testkit.runner.TaskOutcome import org.gradle.util.GradleVersion +import org.junit.runners.Parameterized import java.io.File -import kotlin.test.BeforeTest -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertTrue +import kotlin.test.* -class Multiplatform0GradleIntegrationTest : AbstractDefaultVersionsGradleIntegrationTest( - minGradleVersion = GradleVersion.version("6.0.0") -) { +class Multiplatform0GradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() { + + companion object { + @get:JvmStatic + @get:Parameterized.Parameters(name = "{0}") + val versions = BuildVersions.permutations( + gradleVersions = listOf("6.5.1", "6.1.1"), + kotlinVersions = listOf("1.3.30", "1.3.72", "1.4-M2-eap-70") + ) + } @BeforeTest fun prepareProjectFiles() { @@ -21,11 +26,9 @@ class Multiplatform0GradleIntegrationTest : AbstractDefaultVersionsGradleIntegra File(templateProjectDir, "src").copyRecursively(File(projectDir, "src")) } - override fun execute(versions: BuildVersions) { - val result = createGradleRunner( - buildVersions = versions, - arguments = arrayOf("dokka", "--stacktrace") - ).build() + @Test + fun execute() { + val result = createGradleRunner("dokka", "--stacktrace").build() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokka")).outcome) @@ -37,5 +40,4 @@ class Multiplatform0GradleIntegrationTest : AbstractDefaultVersionsGradleIntegra assertNoUnresolvedLInks(file) } } - } 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 - } -} |