diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2020-12-17 12:14:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 12:14:40 +0100 |
commit | fea7c42733a339ed19fc7471bb064f53de71cc6b (patch) | |
tree | b3386822c1903026d079b8875bf3508ef20171e4 /core/test-api/src/main/kotlin/testApi | |
parent | 2f7ee2b82cda39f6bd94c5200b83563418b68dd7 (diff) | |
download | dokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.tar.gz dokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.tar.bz2 dokka-fea7c42733a339ed19fc7471bb064f53de71cc6b.zip |
Multimodule tests (#1670)
* Multimodule tests
* Multimodule tests
Diffstat (limited to 'core/test-api/src/main/kotlin/testApi')
-rw-r--r-- | core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt | 7 | ||||
-rw-r--r-- | core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt | 26 |
2 files changed, 19 insertions, 14 deletions
diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt index e3d5016a..87e85c02 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt @@ -26,25 +26,26 @@ class TestDokkaConfigurationBuilder { field = value } var moduleVersion: String = "1.0-SNAPSHOT" - var outputDir: String = "out" + var outputDir: File = File("out") var format: String = "html" var offlineMode: Boolean = false var cacheRoot: String? = null var pluginsClasspath: List<File> = emptyList() var pluginsConfigurations: MutableList<PluginConfigurationImpl> = mutableListOf() var failOnWarning: Boolean = false + var modules: List<DokkaModuleDescriptionImpl> = emptyList() private val lazySourceSets = mutableListOf<Lazy<DokkaSourceSetImpl>>() fun build() = DokkaConfigurationImpl( moduleName = moduleName, moduleVersion = moduleVersion, - outputDir = File(outputDir), + outputDir = outputDir, cacheRoot = cacheRoot?.let(::File), offlineMode = offlineMode, sourceSets = lazySourceSets.map { it.value }.toList(), pluginsClasspath = pluginsClasspath, pluginsConfiguration = pluginsConfigurations, - modules = emptyList(), + modules = modules, failOnWarning = failOnWarning, ) diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index 1e758fec..9a010135 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -7,7 +7,6 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.testApi.logger.TestLogger -import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.DokkaLogger import org.junit.rules.TemporaryFolder import testApi.testRunner.TestDokkaConfigurationBuilder @@ -20,7 +19,7 @@ import java.nio.file.Path import java.nio.file.Paths // TODO: take dokka configuration from file -abstract class AbstractTest< M: TestMethods, T : TestBuilder<M>, D: DokkaTestGenerator<M> >( +abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : DokkaTestGenerator<M>>( protected val testBuilder: () -> T, protected val dokkaTestGenerator: (DokkaConfiguration, DokkaLogger, M, List<DokkaPlugin>) -> D, protected val logger: TestLogger, @@ -32,19 +31,22 @@ abstract class AbstractTest< M: TestMethods, T : TestBuilder<M>, D: DokkaTestGen protected fun testFromData( configuration: DokkaConfigurationImpl, cleanupOutput: Boolean = true, + preserveOutputLocation: Boolean = false, pluginOverrides: List<DokkaPlugin> = emptyList(), block: T.() -> Unit ) { val testMethods = testBuilder().apply(block).build() - val tempDir = getTempDir(cleanupOutput) - if (!cleanupOutput) - logger.info("Output generated under: ${tempDir.root.absolutePath}") - val newConfiguration = + val configurationToUse = if (!preserveOutputLocation) { + val tempDir = getTempDir(cleanupOutput) + if (!cleanupOutput) + logger.info("Output generated under: ${tempDir.root.absolutePath}") configuration.copy( outputDir = tempDir.root ) + } else configuration + dokkaTestGenerator( - newConfiguration, + configurationToUse, logger, testMethods, pluginOverrides @@ -169,7 +171,9 @@ abstract class AbstractTest< M: TestMethods, T : TestBuilder<M>, D: DokkaTestGen } } -open class TestMethods( +interface TestMethods + +open class CoreTestMethods( open val pluginsSetupStage: (DokkaContext) -> Unit, open val verificationStage: (() -> Unit) -> Unit, open val documentablesCreationStage: (List<DModule>) -> Unit, @@ -178,13 +182,13 @@ open class TestMethods( open val pagesGenerationStage: (RootPageNode) -> Unit, open val pagesTransformationStage: (RootPageNode) -> Unit, open val renderingStage: (RootPageNode, DokkaContext) -> Unit -) +) : TestMethods -abstract class TestBuilder<M: TestMethods> { +abstract class TestBuilder<M : TestMethods> { abstract fun build(): M } -abstract class DokkaTestGenerator<T: TestMethods>( +abstract class DokkaTestGenerator<T : TestMethods>( protected val configuration: DokkaConfiguration, protected val logger: DokkaLogger, protected val testMethods: T, |