Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise they would be ignored according .gitignore settings. Probably they should be deleted from repo. Interop/.idea/compiler.xml Interop/.idea/gradle.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml Interop/.idea/modules.xml Interop/.idea/modules/Indexer/Indexer.iml Interop/.idea/modules/Runtime/Runtime.iml Interop/.idea/modules/StubGenerator/StubGenerator.iml backend.native/backend.native.iml backend.native/bc.frontend/bc.frontend.iml backend.native/cli.bc/cli.bc.iml backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt backend.native/tests/link/lib/foo.kt backend.native/tests/link/lib/foo2.kt backend.native/tests/teamcity-test.property
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Code Coverage usage sample
|
||||
|
||||
This example shows how to collect coverage information during execution of the test suite.
|
||||
Please note that this functionality will be incorporated into Gradle plugin so you won't need to do it by hand in the nearest future.
|
||||
|
||||
### Prerequisites
|
||||
`createCoverageReport` task requires `llvm-profdata` and `llvm-cov` to be added to the `$PATH`.
|
||||
They can be found in the Kotlin/Native dependencies dir. By default it should look like
|
||||
`$HOME/.konan/dependencies/clang-llvm-6.0.1-darwin-macos/bin`
|
||||
|
||||
### Usage
|
||||
Just run `createCoverageReport` task.
|
||||
@@ -0,0 +1,49 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
|
||||
// Create a target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("coverage")
|
||||
hostOs == "Linux" -> linuxX64("coverage")
|
||||
isMingwX64 -> mingwX64("coverage")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable(listOf(DEBUG))
|
||||
}
|
||||
binaries.getTest("DEBUG").apply {
|
||||
freeCompilerArgs += listOf("-Xlibrary-to-cover=${compilations["main"].output.classesDirs.singleFile.absolutePath}")
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val coverageMain by getting
|
||||
val coverageTest by getting
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("createCoverageReport") {
|
||||
dependsOn("coverageTest")
|
||||
|
||||
description = "Create coverage report"
|
||||
|
||||
doLast {
|
||||
val testDebugBinary = kotlin.targets["coverage"].let { it as KotlinNativeTarget }.binaries.getTest("DEBUG").outputFile
|
||||
exec {
|
||||
commandLine("llvm-profdata", "merge", "$testDebugBinary.profraw", "-o", "$testDebugBinary.profdata")
|
||||
}
|
||||
exec {
|
||||
commandLine("llvm-cov", "show", "$testDebugBinary", "-instr-profile", "$testDebugBinary.profdata")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
||||
@@ -0,0 +1,17 @@
|
||||
fun baz(args: Array<String>) {
|
||||
if (args.size > 4) {
|
||||
println("Too many")
|
||||
} else {
|
||||
println("Fine")
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
init {
|
||||
println("A::init")
|
||||
}
|
||||
|
||||
fun f() {
|
||||
println("A::f")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main() {
|
||||
baz(arrayOf("abc"))
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CoverageTests {
|
||||
@Test
|
||||
fun testHello() {
|
||||
main()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testA() {
|
||||
val a = A()
|
||||
a.f()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user