48 lines
1.3 KiB
Kotlin
48 lines
1.3 KiB
Kotlin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
|
|
|
plugins {
|
|
id("org.jetbrains.kotlin.multiplatform")
|
|
}
|
|
|
|
kotlin {
|
|
sourceSets {
|
|
val commonMain by getting {
|
|
dependencies {
|
|
implementation(kotlin("stdlib-common"))
|
|
}
|
|
}
|
|
val commonTest by getting {
|
|
dependencies {
|
|
implementation(kotlin("test-common"))
|
|
implementation(kotlin("test-annotations-common"))
|
|
}
|
|
}
|
|
}
|
|
|
|
macosX64("macos") {
|
|
binaries {
|
|
executable(listOf(DEBUG))
|
|
}
|
|
binaries.getExecutable("test", DEBUG).apply {
|
|
freeCompilerArgs = mutableListOf(
|
|
"-Xlibrary-to-cover=${compilations["main"].output.classesDirs.singleFile.absolutePath}"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.create("createCoverageReport") {
|
|
dependsOn("macosTest")
|
|
|
|
description = "Create coverage report"
|
|
|
|
doLast {
|
|
val testDebugBinary = kotlin.targets["macos"].let { it as KotlinNativeTarget }.binaries.getExecutable("test", "debug").outputFile
|
|
exec {
|
|
commandLine("llvm-profdata", "merge", "$testDebugBinary.profraw", "-o", "$testDebugBinary.profdata")
|
|
}
|
|
exec {
|
|
commandLine("llvm-cov", "show", "$testDebugBinary", "-instr-profile", "$testDebugBinary.profdata")
|
|
}
|
|
}
|
|
} |