diff --git a/kotlin-native/Interop/Indexer/build.gradle.kts b/kotlin-native/Interop/Indexer/build.gradle.kts index 8e4ad1f33a5..62a3c22c0c3 100644 --- a/kotlin-native/Interop/Indexer/build.gradle.kts +++ b/kotlin-native/Interop/Indexer/build.gradle.kts @@ -152,6 +152,8 @@ sourceSets { dependencies { compile(project(":kotlin-stdlib")) compile(project(":kotlin-native:Interop:Runtime")) + + testImplementation(kotlin("test-junit")) } val nativelibs = project.tasks.create("nativelibs") { @@ -180,6 +182,25 @@ tasks.withType().configureEach } } +tasks.withType().configureEach { + val projectsWithNativeLibs = listOf( + project, // Current one. + project(":kotlin-native:Interop:Runtime") + ) + dependsOn(projectsWithNativeLibs.map { "${it.path}:nativelibs" }) + systemProperty("java.library.path", projectsWithNativeLibs.joinToString(File.pathSeparator) { + File(it.buildDir, "nativelibs").absolutePath + }) + + systemProperty("kotlin.native.llvm.libclang", "$llvmDir/" + if (HostManager.hostIsMingw) { + "bin/libclang.dll" + } else { + "lib/${System.mapLibraryName("clang")}" + }) + + systemProperty("kotlin.native.interop.indexer.temp", File(buildDir, "testTemp")) +} + tasks.matching { it.name == "linkClangstubsSharedLibrary" }.all { dependsOn(libclangextTask) inputs.dir(libclangextDir) diff --git a/kotlin-native/Interop/Indexer/src/test/kotlin/org/jetbrains/kotlin/native/interop/indexer/IndexerTests.kt b/kotlin-native/Interop/Indexer/src/test/kotlin/org/jetbrains/kotlin/native/interop/indexer/IndexerTests.kt new file mode 100644 index 00000000000..33fa6be8fad --- /dev/null +++ b/kotlin-native/Interop/Indexer/src/test/kotlin/org/jetbrains/kotlin/native/interop/indexer/IndexerTests.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.native.interop.indexer + +import java.io.File + +open class IndexerTests { + init { + System.load(System.getProperty("kotlin.native.llvm.libclang")) + } + + class TempFiles(name: String) { + private val tempRootDir = System.getProperty("kotlin.native.interop.indexer.temp") ?: System.getProperty("java.io.tmpdir") ?: "." + + val directory: File = File(tempRootDir, name).canonicalFile.also { + it.mkdirs() + } + + fun file(relativePath: String, contents: String): File = File(directory, relativePath).canonicalFile.apply { + parentFile.mkdirs() + writeText(contents) + } + } +} diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 98db1c852a6..edc9a8bdbd5 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -201,6 +201,7 @@ run { // Add regular gradle test tasks dependsOn(tasksOf(Test)) dependsOn(tasksOf(CoverageTest)) + dependsOn(":kotlin-native:Interop:Indexer:check") } task sanity { @@ -210,6 +211,7 @@ task sanity { // Add regular gradle test tasks dependsOn(tasksOf(Test)) dependsOn(tasksOf(CoverageTest)) + dependsOn(":kotlin-native:Interop:Indexer:check") } // Collect reports in one json.