From fa6e8ab0b0a846192d46cf9d13a0e4f01262432f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Sat, 15 Sep 2018 15:45:15 +0200 Subject: Add integration test for type safe configuration by leveraging Groovy's @CompileStatic Signed-off-by: Paul Merlin --- .../dokka/gradle/TypeSafeConfigurationTest.kt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt (limited to 'runners/gradle-integration-tests/src/test/kotlin') diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt new file mode 100644 index 00000000..ab8bc62b --- /dev/null +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt @@ -0,0 +1,38 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.testkit.runner.TaskOutcome +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import kotlin.test.assertEquals + +@RunWith(Parameterized::class) +class TypeSafeConfigurationTest(private val testCase: TestCase) : AbstractDokkaGradleTest() { + + data class TestCase(val gradleVersion: String, val kotlinVersion: String) { + override fun toString(): String = "Gradle $gradleVersion and Kotlin $kotlinVersion" + } + + companion object { + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun testCases() = listOf( + TestCase("4.0", "1.1.2"), + TestCase("4.5", "1.2.20"), + TestCase("4.10.1", "1.2.60") + ) + } + + @Test + fun test() { + testDataFolder.resolve("typeSafeConfiguration").toFile().copyRecursively(testProjectDir.root) + configure( + testCase.gradleVersion, + testCase.kotlinVersion, + arguments = arrayOf("help", "-s") + ).build().apply { + println(output) + assertEquals(TaskOutcome.SUCCESS, task(":help")?.outcome) + } + } +} \ No newline at end of file -- cgit From a32ce3282935b382f285f66c65484409d96328c7 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Sat, 15 Sep 2018 16:34:04 +0200 Subject: Refine type safe configuration test Signed-off-by: Paul Merlin --- .../dokka/gradle/TypeSafeConfigurationTest.kt | 14 ++- .../testData/typeSafeConfiguration/build.gradle | 116 ++++++++++----------- 2 files changed, 64 insertions(+), 66 deletions(-) (limited to 'runners/gradle-integration-tests/src/test/kotlin') diff --git a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt index ab8bc62b..7b179e92 100644 --- a/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt +++ b/runners/gradle-integration-tests/src/test/kotlin/org/jetbrains/dokka/gradle/TypeSafeConfigurationTest.kt @@ -1,10 +1,8 @@ package org.jetbrains.dokka.gradle -import org.gradle.testkit.runner.TaskOutcome import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized -import kotlin.test.assertEquals @RunWith(Parameterized::class) class TypeSafeConfigurationTest(private val testCase: TestCase) : AbstractDokkaGradleTest() { @@ -25,14 +23,14 @@ class TypeSafeConfigurationTest(private val testCase: TestCase) : AbstractDokkaG @Test fun test() { - testDataFolder.resolve("typeSafeConfiguration").toFile().copyRecursively(testProjectDir.root) + + testDataFolder.resolve("typeSafeConfiguration").toFile() + .copyRecursively(testProjectDir.root) + configure( testCase.gradleVersion, testCase.kotlinVersion, arguments = arrayOf("help", "-s") - ).build().apply { - println(output) - assertEquals(TaskOutcome.SUCCESS, task(":help")?.outcome) - } + ).build() } -} \ No newline at end of file +} diff --git a/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle b/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle index 923c07d8..327cead8 100644 --- a/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle +++ b/runners/gradle-integration-tests/testData/typeSafeConfiguration/build.gradle @@ -21,64 +21,64 @@ plugins { apply plugin: 'kotlin' @CompileStatic -def configureDokkaTypeSafely(Project project) { - project.tasks.withType(DokkaTask) { DokkaTask dokka -> - dokka.with { - moduleName = "some String" - outputFormat = "some String" - outputDirectory = "some String" - classpath = Collections.singleton(file("someClassDir")) - includes = Collections.emptyList() - linkMappings = new ArrayList() - samples = Collections.emptyList() - jdkVersion = 6 - sourceDirs = Collections.emptyList() - sourceRoots = new ArrayList() - dokkaFatJar = file("some File") - includeNonPublic = false - skipDeprecated = false - skipEmptyPackages = true - reportUndocumented = true - perPackageOptions = new ArrayList() - impliedPlatforms = Collections.emptyList() - externalDocumentationLinks = new ArrayList() - noStdlibLink = false - cacheRoot = null as String - languageVersion = null as String - apiVersion = null as String - kotlinTasks(new Callable>() { - @Override - List call() { - return defaultKotlinTasks() - } - }) - linkMapping(new Action() { - @Override - void execute(LinkMapping mapping) { - mapping.dir = "some String" - mapping.url = "some String" - } - }) - sourceRoot(new Action() { - @Override - void execute(SourceRoot sourceRoot) { - sourceRoot.path = "some String" - } - }) - packageOptions(new Action() { - @Override - void execute(PackageOptions packageOptions) { - packageOptions.prefix = "some String" - } - }) - externalDocumentationLink(new Action() { - @Override - void execute(DokkaConfiguration.ExternalDocumentationLink.Builder builder) { - builder.url = uri("some URI").toURL() - } - }) - } +def configureDokkaTypeSafely(DokkaTask dokka) { + dokka.with { + moduleName = "some String" + outputFormat = "some String" + outputDirectory = "some String" + classpath = Collections.singleton(file("someClassDir")) + includes = Collections.emptyList() + linkMappings = new ArrayList() + samples = Collections.emptyList() + jdkVersion = 6 + sourceDirs = Collections.emptyList() + sourceRoots = new ArrayList() + dokkaFatJar = file("some File") + includeNonPublic = false + skipDeprecated = false + skipEmptyPackages = true + reportUndocumented = true + perPackageOptions = new ArrayList() + impliedPlatforms = Collections.emptyList() + externalDocumentationLinks = new ArrayList() + noStdlibLink = false + cacheRoot = null as String + languageVersion = null as String + apiVersion = null as String + kotlinTasks(new Callable>() { + @Override + List call() { + return defaultKotlinTasks() + } + }) + linkMapping(new Action() { + @Override + void execute(LinkMapping mapping) { + mapping.dir = "some String" + mapping.url = "some String" + } + }) + sourceRoot(new Action() { + @Override + void execute(SourceRoot sourceRoot) { + sourceRoot.path = "some String" + } + }) + packageOptions(new Action() { + @Override + void execute(PackageOptions packageOptions) { + packageOptions.prefix = "some String" + } + }) + externalDocumentationLink(new Action() { + @Override + void execute(DokkaConfiguration.ExternalDocumentationLink.Builder builder) { + builder.url = uri("some URI").toURL() + } + }) } } -configureDokkaTypeSafely(project) +project.tasks.withType(DokkaTask) { dokka -> + configureDokkaTypeSafely(dokka) +} -- cgit