diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-04-19 13:37:12 +0200 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-04-19 13:37:12 +0200 |
commit | c9be7ce9fd73d15d8bce7ba9cf57fe1c6e3cc1d2 (patch) | |
tree | 9766b5995e64d52aa689d517f53e6fb71ac095e7 | |
parent | a2faa6e7b08872770511f85099263d64ad6a1a55 (diff) | |
download | dokka-c9be7ce9fd73d15d8bce7ba9cf57fe1c6e3cc1d2.tar.gz dokka-c9be7ce9fd73d15d8bce7ba9cf57fe1c6e3cc1d2.tar.bz2 dokka-c9be7ce9fd73d15d8bce7ba9cf57fe1c6e3cc1d2.zip |
Fix hardcoded classpaths for TestAPI
-rw-r--r-- | core/build.gradle | 3 | ||||
-rw-r--r-- | core/src/test/kotlin/TestAPI.kt | 156 |
2 files changed, 81 insertions, 78 deletions
diff --git a/core/build.gradle b/core/build.gradle index 1a2eb527..697fd726 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -48,6 +48,7 @@ dependencies { testCompile group: 'org.jetbrains.kotlin', name: 'kotlin-test-junit', version: kotlin_version testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0" implementation "com.google.code.gson:gson:$gson_version" - testCompile ideaRT() + testImplementation "org.jetbrains.kotlin:kotlin-stdlib-js:$bundled_kotlin_compiler_version" + testImplementation "org.jetbrains.kotlin:kotlin-stdlib-common:$bundled_kotlin_compiler_version" }
\ No newline at end of file diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 6ee610cd..ca423b1a 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -20,18 +20,19 @@ import org.jetbrains.kotlin.utils.PathUtil import org.junit.Assert import org.junit.Assert.fail import java.io.File + data class ModelConfig( - val roots: Array<ContentRoot> = arrayOf(), - val withJdk: Boolean = false, - val withKotlinRuntime: Boolean = false, - val format: String = "html", - val includeNonPublic: Boolean = true, - val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(), - val analysisPlatform: Platform = Platform.DEFAULT, - val defaultPlatforms: List<String> = emptyList(), - val noStdlibLink: Boolean = true, - val collectInheritedExtensionsFromLibraries: Boolean = false, - val sourceLinks: List<SourceLinkDefinition> = emptyList() + val roots: Array<ContentRoot> = arrayOf(), + val withJdk: Boolean = false, + val withKotlinRuntime: Boolean = false, + val format: String = "html", + val includeNonPublic: Boolean = true, + val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(), + val analysisPlatform: Platform = Platform.DEFAULT, + val defaultPlatforms: List<String> = emptyList(), + val noStdlibLink: Boolean = true, + val collectInheritedExtensionsFromLibraries: Boolean = false, + val sourceLinks: List<SourceLinkDefinition> = emptyList() ) fun verifyModel(modelConfig: ModelConfig, @@ -39,23 +40,23 @@ fun verifyModel(modelConfig: ModelConfig, val documentation = DocumentationModule("test") val passConfiguration = PassConfigurationImpl ( - includeNonPublic = modelConfig.includeNonPublic, - skipEmptyPackages = false, - includeRootPackage = true, - sourceLinks = modelConfig.sourceLinks, - perPackageOptions = modelConfig.perPackageOptions, - noStdlibLink = modelConfig.noStdlibLink, - noJdkLink = false, - languageVersion = null, - apiVersion = null, - collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries + includeNonPublic = modelConfig.includeNonPublic, + skipEmptyPackages = false, + includeRootPackage = true, + sourceLinks = modelConfig.sourceLinks, + perPackageOptions = modelConfig.perPackageOptions, + noStdlibLink = modelConfig.noStdlibLink, + noJdkLink = false, + languageVersion = null, + apiVersion = null, + collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries ) val configuration = DokkaConfigurationImpl( - outputDir = "", - format = modelConfig.format, - generateIndexPages = false, - cacheRoot = "default", - passesConfigurations = listOf(passConfiguration) + outputDir = "", + format = modelConfig.format, + generateIndexPages = false, + cacheRoot = "default", + passesConfigurations = listOf(passConfiguration) ) appendDocumentation(documentation, configuration, passConfiguration, modelConfig) @@ -103,14 +104,15 @@ fun appendDocumentation(documentation: DocumentationModule, val kotlinStrictfpRoot = PathManager.getResourceRoot(Strictfp::class.java, "/kotlin/jvm/Strictfp.class") addClasspath(File(kotlinStrictfpRoot)) } - // TODO: Fix concrete path to correct gradle path providing if (analysisPlatform == Platform.js) { - addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-jslib.jar")) - addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-js.jar")) - addClasspath(File("/home/jetbrains/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.5281.24/plugins/Kotlin/kotlinc/lib/kotlin-stdlib-js-sources.jar")) - } + val kotlinStdlibJsRoot = PathManager.getResourceRoot(Any::class.java, "/kotlin/jquery") + addClasspath(File(kotlinStdlibJsRoot)) + } + if (analysisPlatform == Platform.common) { - addClasspath(File("/home/jetbrains/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.2.51/e4a9d4b13ab19ed1e6531fce6df98e8cfa7f7301/kotlin-stdlib-common-1.2.51.jar")) + // TODO: Feels hacky + val kotlinStdlibCommonRoot = ClassLoader.getSystemResource("kotlin/UInt.kotlin_metadata") + addClasspath(File(kotlinStdlibCommonRoot.file.replace("file:", "").replaceAfter(".jar", ""))) } } addRoots(modelConfig.roots.toList()) @@ -122,18 +124,18 @@ fun appendDocumentation(documentation: DocumentationModule, } val globalInjector = Guice.createInjector( - DokkaRunModule(dokkaConfiguration) + DokkaRunModule(dokkaConfiguration) ) val injector = globalInjector.createChildInjector( - DokkaAnalysisModule( - environment, - dokkaConfiguration, - defaultPlatformsProvider, - documentation.nodeRefGraph, - passConfiguration, - DokkaConsoleLogger - ) + DokkaAnalysisModule( + environment, + dokkaConfiguration, + defaultPlatformsProvider, + documentation.nodeRefGraph, + passConfiguration, + DokkaConsoleLogger + ) ) buildDocumentationModule(injector, documentation) @@ -141,23 +143,23 @@ fun appendDocumentation(documentation: DocumentationModule, } fun checkSourceExistsAndVerifyModel(source: String, - modelConfig: ModelConfig = ModelConfig(), - verifier: (DocumentationModule) -> Unit) { + modelConfig: ModelConfig = ModelConfig(), + verifier: (DocumentationModule) -> Unit) { require (File(source).exists()) { "Cannot find test data file $source" } verifyModel( - ModelConfig( - roots = arrayOf(contentRootFromPath(source)), - withJdk = modelConfig.withJdk, - withKotlinRuntime = modelConfig.withKotlinRuntime, - format = modelConfig.format, - includeNonPublic = modelConfig.includeNonPublic, - sourceLinks = modelConfig.sourceLinks, - analysisPlatform = modelConfig.analysisPlatform - ), + ModelConfig( + roots = arrayOf(contentRootFromPath(source)), + withJdk = modelConfig.withJdk, + withKotlinRuntime = modelConfig.withKotlinRuntime, + format = modelConfig.format, + includeNonPublic = modelConfig.includeNonPublic, + sourceLinks = modelConfig.sourceLinks, + analysisPlatform = modelConfig.analysisPlatform + ), - verifier = verifier + verifier = verifier ) } @@ -165,12 +167,12 @@ fun verifyPackageMember(source: String, modelConfig: ModelConfig = ModelConfig(), verifier: (DocumentationNode) -> Unit) { checkSourceExistsAndVerifyModel( - source, - modelConfig = ModelConfig( - withJdk = modelConfig.withJdk, - withKotlinRuntime = modelConfig.withKotlinRuntime, - analysisPlatform = modelConfig.analysisPlatform - ) + source, + modelConfig = ModelConfig( + withJdk = modelConfig.withJdk, + withKotlinRuntime = modelConfig.withKotlinRuntime, + analysisPlatform = modelConfig.analysisPlatform + ) ) { model -> val pkg = model.members.single() verifier(pkg.members.single()) @@ -185,13 +187,13 @@ fun verifyJavaModel(source: String, val sourceFile = File(source) FileUtil.copy(sourceFile, File(tempDir, sourceFile.name)) verifyModel( - ModelConfig( - roots = arrayOf(JavaSourceRoot(tempDir, null)), - withJdk = true, - withKotlinRuntime = modelConfig.withKotlinRuntime, - analysisPlatform = modelConfig.analysisPlatform - ), - verifier = verifier + ModelConfig( + roots = arrayOf(JavaSourceRoot(tempDir, null)), + withJdk = true, + withKotlinRuntime = modelConfig.withKotlinRuntime, + analysisPlatform = modelConfig.analysisPlatform + ), + verifier = verifier ) } finally { @@ -221,18 +223,18 @@ fun verifyOutput(path: String, modelConfig: ModelConfig = ModelConfig(), outputGenerator: (DocumentationModule, StringBuilder) -> Unit) { verifyOutput( - ModelConfig( - roots = arrayOf(contentRootFromPath(path)) + modelConfig.roots, - withJdk = modelConfig.withJdk, - withKotlinRuntime = modelConfig.withKotlinRuntime, - format = modelConfig.format, - includeNonPublic = modelConfig.includeNonPublic, - analysisPlatform = modelConfig.analysisPlatform, - noStdlibLink = modelConfig.noStdlibLink, - collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries + ModelConfig( + roots = arrayOf(contentRootFromPath(path)) + modelConfig.roots, + withJdk = modelConfig.withJdk, + withKotlinRuntime = modelConfig.withKotlinRuntime, + format = modelConfig.format, + includeNonPublic = modelConfig.includeNonPublic, + analysisPlatform = modelConfig.analysisPlatform, + noStdlibLink = modelConfig.noStdlibLink, + collectInheritedExtensionsFromLibraries = modelConfig.collectInheritedExtensionsFromLibraries ), - outputExtension, - outputGenerator + outputExtension, + outputGenerator ) } |