[K/N] Remove LLVM coverage
The -Xcoverage feature has not worked and has been disabled for a while. This fix removes it, and all of its uses. Co-authored-by: Troels Lund <troels@google.com> Merge-request: KOTLIN-MR-821 Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This commit is contained in:
committed by
Space Cloud
parent
e0c931f69d
commit
4f77434ea5
@@ -123,9 +123,6 @@ allprojects {
|
||||
// backend.native/tests/framework
|
||||
ext.testOutputFramework = rootProject.file("$testOutputRoot/framework")
|
||||
|
||||
// backent.native/tests/coverage
|
||||
ext.testOutputCoverage = rootProject.file("$testOutputRoot/coverage")
|
||||
|
||||
ext.testOutputFileCheck = rootProject.file("$testOutputRoot/filecheck")
|
||||
}
|
||||
testOutputExternal.mkdirs()
|
||||
@@ -187,7 +184,6 @@ tasks.named("run") {
|
||||
dependsOn(tasks.withType(FrameworkTest).matching { it.enabled })
|
||||
// Add regular gradle test tasks
|
||||
dependsOn(tasks.withType(Test).matching { it.enabled })
|
||||
dependsOn(tasks.withType(CoverageTest).matching { it.enabled })
|
||||
dependsOn(tasks.withType(FileCheckTest).matching { it.enabled })
|
||||
dependsOn(":kotlin-native:Interop:Indexer:check")
|
||||
dependsOn(":kotlin-native:Interop:StubGenerator:check")
|
||||
@@ -5080,112 +5076,6 @@ if (isAppleTarget(project)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilsKt.getTestTargetSupportsCodeCoverage(project)) {
|
||||
tasks.register("coverage_basic_program", CoverageTest) {
|
||||
|
||||
binaryName = "CoverageBasic"
|
||||
numberOfCoveredFunctions = 1
|
||||
numberOfCoveredLines = 3
|
||||
|
||||
konanArtifacts {
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcDir 'coverage/basic/program'
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.program.main"
|
||||
extraOpts "-Xcoverage", "-Xcoverage-file=$profrawFile"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("coverage_basic_library", CoverageTest) {
|
||||
|
||||
binaryName = "CoverageBasicLibrary"
|
||||
numberOfCoveredFunctions = 1
|
||||
numberOfCoveredLines = 1
|
||||
|
||||
konanArtifacts {
|
||||
library("lib_to_cover", targets: [target.name]) {
|
||||
srcFiles 'coverage/basic/library/library.kt'
|
||||
}
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcFiles 'coverage/basic/library/main.kt'
|
||||
libraries {
|
||||
artifact konanArtifacts.lib_to_cover
|
||||
}
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.library.main"
|
||||
extraOpts "-Xcoverage-file=$profrawFile", "-Xlibrary-to-cover=${konanArtifacts.lib_to_cover.getArtifactByTarget(target.name)}"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("coverage_controlflow", CoverageTest) {
|
||||
binaryName = "CoverageControlFlow"
|
||||
numberOfCoveredFunctions = 1
|
||||
numberOfCoveredLines = 102
|
||||
|
||||
konanArtifacts {
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcDir 'coverage/basic/controlflow'
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.controlflow.main"
|
||||
extraOpts "-Xcoverage", "-Xcoverage-file=$profrawFile"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("coverage_jumps", CoverageTest) {
|
||||
binaryName = "CoverageJumps"
|
||||
numberOfCoveredFunctions = 8
|
||||
numberOfCoveredLines = 74
|
||||
|
||||
konanArtifacts {
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcDir 'coverage/basic/jumps'
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.jumps.main"
|
||||
extraOpts "-Xcoverage", "-Xcoverage-file=$profrawFile"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("coverage_smoke0", CoverageTest) {
|
||||
binaryName = "CoverageSmoke0"
|
||||
numberOfCoveredFunctions = 2
|
||||
numberOfCoveredLines = 5
|
||||
|
||||
konanArtifacts {
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcDir 'coverage/basic/smoke0'
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.smoke0.main"
|
||||
extraOpts "-Xcoverage", "-Xcoverage-file=$profrawFile"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("coverage_smoke1", CoverageTest) {
|
||||
binaryName = "CoverageSmoke1"
|
||||
numberOfCoveredFunctions = 9
|
||||
numberOfCoveredLines = 33
|
||||
|
||||
konanArtifacts {
|
||||
program(binaryName, targets: [ target ]) {
|
||||
srcDir 'coverage/basic/smoke1'
|
||||
baseDir "$testOutputCoverage/$binaryName"
|
||||
entryPoint "coverage.basic.smoke1.main"
|
||||
extraOpts "-Xcoverage", "-Xcoverage-file=$profrawFile"
|
||||
extraOpts project.globalTestArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
standaloneTest("local_ea_arraysfieldwrite") {
|
||||
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|
||||
useGoldenData = true
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
package coverage.basic.controlflow
|
||||
|
||||
fun main() {
|
||||
|
||||
// If Expression
|
||||
|
||||
var a = 1
|
||||
var b = 2
|
||||
if (a < b) println("a < b")
|
||||
|
||||
if (a > b) {
|
||||
println("a > b")
|
||||
} else if (a == b) {
|
||||
println("a == b")
|
||||
} else {
|
||||
println("a < b")
|
||||
}
|
||||
|
||||
if (a < b) {
|
||||
println("a < b")
|
||||
}
|
||||
else
|
||||
{
|
||||
println("a >= b")
|
||||
}
|
||||
|
||||
var max = if (a > b) a else b
|
||||
|
||||
max = if (a > b) {
|
||||
println("Choose a")
|
||||
a
|
||||
} else {
|
||||
println("Choose b")
|
||||
b
|
||||
}
|
||||
|
||||
if (a < b)
|
||||
|
||||
println("a < b")
|
||||
else
|
||||
|
||||
println("a >= b")
|
||||
|
||||
if (a > b)
|
||||
|
||||
println("a > b")
|
||||
|
||||
else
|
||||
|
||||
println("a <= b")
|
||||
|
||||
// When Expression
|
||||
|
||||
when {
|
||||
a < b -> {
|
||||
println("a < b")
|
||||
}
|
||||
|
||||
a == b ->
|
||||
|
||||
println("a == b")
|
||||
a > b -> {
|
||||
println("a > b")
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var x = 1
|
||||
when (x) {
|
||||
1 -> print("x == 1")
|
||||
2 -> print("x == 2")
|
||||
else -> { // Note the block
|
||||
print("x is neither 1 nor 2")
|
||||
}
|
||||
}
|
||||
x = 2
|
||||
when (x) {
|
||||
1 -> print("x == 1")
|
||||
2 -> print("x == 2")
|
||||
else -> { // Note the block
|
||||
print("x is neither 1 nor 2")
|
||||
}
|
||||
}
|
||||
x = 3
|
||||
when (x) {
|
||||
1 -> print("x == 1")
|
||||
2 -> print("x == 2")
|
||||
else -> { // Note the block
|
||||
print("x is neither 1 nor 2")
|
||||
}
|
||||
}
|
||||
|
||||
when (x) {
|
||||
0, 1
|
||||
->
|
||||
print("x == 0 or x == 1")
|
||||
else ->
|
||||
print("otherwise")
|
||||
}
|
||||
|
||||
when {
|
||||
else -> println("=)")
|
||||
}
|
||||
|
||||
// While Loops
|
||||
|
||||
do {
|
||||
b++
|
||||
} while (b < 5)
|
||||
|
||||
while (a < 10) {
|
||||
a++
|
||||
if (a > 7) {
|
||||
println(a)
|
||||
}
|
||||
}
|
||||
|
||||
while (a > 0)
|
||||
|
||||
a--
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package coverage.basic.jumps
|
||||
|
||||
fun simpleReturn(n: Int) {
|
||||
if (n == 0) return
|
||||
println(n)
|
||||
}
|
||||
|
||||
fun returnFromIfBranch(n: Int) {
|
||||
if (n > 0) {
|
||||
if (n > 10) {
|
||||
return
|
||||
}
|
||||
} else if (n < -10) {
|
||||
return
|
||||
} else if (n == 0) {
|
||||
return
|
||||
}
|
||||
println(n)
|
||||
}
|
||||
|
||||
fun returnFromWhenBranch(n: Int) {
|
||||
when {
|
||||
n == 0 -> return
|
||||
n == 1 -> return
|
||||
n == 2 -> {
|
||||
println(n)
|
||||
return
|
||||
}
|
||||
else -> println(n)
|
||||
}
|
||||
}
|
||||
|
||||
fun breakFromWhile() {
|
||||
var a = 7
|
||||
while (true) {
|
||||
if (a < 4) break
|
||||
println(a)
|
||||
a--
|
||||
}
|
||||
}
|
||||
|
||||
fun continueFromDoWhile() {
|
||||
var a = 0
|
||||
do {
|
||||
if (a % 3 == 0) {
|
||||
a++
|
||||
continue
|
||||
}
|
||||
println(a)
|
||||
a++
|
||||
} while (a < 10)
|
||||
}
|
||||
|
||||
fun singleReturn() {
|
||||
return
|
||||
}
|
||||
|
||||
fun nestedReturn() {
|
||||
while (true) {
|
||||
while (true) {
|
||||
while (true) {
|
||||
if (1 < 2) {
|
||||
return
|
||||
}
|
||||
println()
|
||||
}
|
||||
println()
|
||||
}
|
||||
}
|
||||
println()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
simpleReturn(0)
|
||||
simpleReturn(1)
|
||||
|
||||
returnFromIfBranch(1)
|
||||
returnFromIfBranch(11)
|
||||
returnFromIfBranch(-11)
|
||||
returnFromIfBranch(0)
|
||||
|
||||
returnFromWhenBranch(0)
|
||||
returnFromWhenBranch(1)
|
||||
returnFromWhenBranch(2)
|
||||
|
||||
breakFromWhile()
|
||||
continueFromDoWhile()
|
||||
singleReturn()
|
||||
nestedReturn()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package coverage_library
|
||||
|
||||
fun foo() = "foo"
|
||||
@@ -1,5 +0,0 @@
|
||||
package coverage.basic.library
|
||||
|
||||
fun main() {
|
||||
println(coverage_library.foo())
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package coverage.basic.program
|
||||
|
||||
fun main() {
|
||||
println("OK")
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package coverage.basic.smoke0
|
||||
|
||||
data class User(val name: String)
|
||||
|
||||
fun main() {
|
||||
val user = User("Happy Kotlin/Native user")
|
||||
println(user)
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package coverage.basic.smoke1
|
||||
|
||||
class A(val prop: Int) {
|
||||
|
||||
constructor() : this(1)
|
||||
|
||||
fun action1() {
|
||||
println(prop)
|
||||
}
|
||||
|
||||
fun action2() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class B private constructor(val prop: String) {
|
||||
|
||||
init {
|
||||
println("init block")
|
||||
}
|
||||
|
||||
constructor(prop1: String, prop2: String) : this("$prop1, $prop2")
|
||||
|
||||
constructor() : this("dummy") {
|
||||
if (1 > 2) {
|
||||
println("uncovered")
|
||||
} else {
|
||||
println("foo")
|
||||
}
|
||||
println("bar")
|
||||
}
|
||||
|
||||
override fun toString() = prop
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a1 = A(2)
|
||||
a1.action1()
|
||||
a1.action2()
|
||||
val a2 = A()
|
||||
a2.action1()
|
||||
a2.action1()
|
||||
|
||||
val b1 = B("Hello", "world")
|
||||
val b2 = B()
|
||||
println(b1)
|
||||
println(b2)
|
||||
}
|
||||
@@ -58,7 +58,6 @@ val buildSamplesWithPlatformLibs by tasks.creating {
|
||||
dependsOn(":objc:assemble")
|
||||
dependsOn(":opengl:assemble")
|
||||
dependsOn(":uikit:assemble")
|
||||
dependsOn(":coverage:assemble")
|
||||
dependsOn(":watchos:assemble")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
kotlin.code.style=official
|
||||
@@ -1,17 +0,0 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun main() {
|
||||
baz(arrayOf("abc"))
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CoverageTests {
|
||||
@Test
|
||||
fun testHello() {
|
||||
main()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testA() {
|
||||
val a = A()
|
||||
a.f()
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ if (isMacos || isLinux || isWindows) {
|
||||
include(":libcurl")
|
||||
include(":videoplayer")
|
||||
include(":workers")
|
||||
include(":coverage")
|
||||
}
|
||||
|
||||
if (isMacos || isLinux) {
|
||||
|
||||
Reference in New Issue
Block a user