Add jacoco coverage

This commit is contained in:
Leonid Stashevsky
2020-01-23 15:25:24 +03:00
parent b6c494ea84
commit 309854b7e5
9 changed files with 86 additions and 12 deletions

View File

@@ -180,8 +180,11 @@ allprojects {
}
}
}
}
task rootAllTest(type: org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport) {
def rootAllTest = it
destinationDir = new File(project.buildDir, "reports/tests/rootAllTest")
@@ -256,3 +259,70 @@ afterEvaluate {
reportUndocumented = false
}
}
allprojects {
apply plugin: "jacoco"
jacoco {
toolVersion = "0.8.5"
reportsDir = file("${buildDir}/jacoco-reports")
}
}
subprojects {
task testCoverage(type: JacocoReport, dependsOn: jvmTest) {
group = "Reporting"
description = "Generate Jacoco coverage reports."
def coverageSourceDirs = [
"common/src",
"jvm/src"
]
classDirectories.from files(fileTree(dir: "${buildDir}/classes/kotlin/jvm/"))
sourceDirectories.from files(coverageSourceDirs)
additionalSourceDirs.from files(coverageSourceDirs)
executionData.from files("${buildDir}/jacoco/jvmTest.exec")
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${buildDir}/jacoco-reports/html")
}
}
}
def findSources(sourceSet) {
return files(subprojects.findResults {
it.kotlin.sourceSets.findByName("jvmMain")?.kotlin?.srcDirs
})
}
task testCoverage(type: JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage reports."
dependsOn subprojects.testCoverage
def coverageSourceDirs = (
findSources("commonMain") + findSources("jvmMain") + findSources("commonTest") + findSources("jvmTest")
)
def classes = files(subprojects.collect {
files(fileTree(dir: "${it.buildDir}/classes/kotlin/jvm"))
})
def samples = files(subprojects.testCoverage.executionData).findAll { it.exists() }
classDirectories.from files(classes)
sourceDirectories.from files(coverageSourceDirs)
additionalSourceDirs.from files(coverageSourceDirs)
executionData.from(samples)
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${buildDir}/jacoco-reports/html")
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty
@@ -13,10 +13,14 @@ import org.junit.*
import javax.servlet.*
class JettyAsyncServletContainerEngineTest :
EngineTestSuite<JettyApplicationEngineBase, JettyApplicationEngineBase.Configuration>(Servlet(async = true))
EngineTestSuite<JettyApplicationEngineBase, JettyApplicationEngineBase.Configuration>(
Servlet(async = true)
)
class JettyBlockingServletContainerEngineTest :
EngineTestSuite<JettyApplicationEngineBase, JettyApplicationEngineBase.Configuration>(Servlet(async = false)) {
EngineTestSuite<JettyApplicationEngineBase, JettyApplicationEngineBase.Configuration>(
Servlet(async = false)
) {
@Ignore
override fun testUpgrade() {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty

View File

@@ -1,8 +1,8 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty
package io.ktor.tests.server.jetty.http2
import io.ktor.server.jetty.*
import io.ktor.server.testing.*

View File

@@ -2,7 +2,7 @@
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty
package io.ktor.tests.server.jetty.http2
import io.ktor.server.engine.*
import io.ktor.server.jetty.*

View File

@@ -1,8 +1,8 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package io.ktor.tests.server.jetty
package io.ktor.tests.server.jetty.http2
import io.ktor.application.*
import io.ktor.response.*