Native: support writing unit tests for Interop/Indexer
This commit is contained in:
committed by
Space
parent
b603f99863
commit
ae349846e1
@@ -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<Copy>("nativelibs") {
|
||||
@@ -180,6 +182,25 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test>().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)
|
||||
|
||||
+27
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user