re-add jacoco coverage to bc and bbc tests

and fix dependency to translations for infix, should also use de_CH in
bc-tests
This commit is contained in:
Robert Stoll
2021-01-08 23:02:33 +01:00
parent d1fa52871e
commit 3db8cbea93
5 changed files with 96 additions and 18 deletions

View File

@@ -18,7 +18,7 @@ jobs:
- name: bbcTests
env:
BC: 1
run: ./gradlew bbcTests
run: ./gradlew bbcTests --stacktrace
- name: Upload windows build code coverage
uses: codecov/codecov-action@v1

View File

@@ -18,7 +18,7 @@ jobs:
- name: bcTests
env:
BC: 1
run: ./gradlew bcTests
run: ./gradlew bcTests --stacktrace
- name: Upload windows build code coverage
uses: codecov/codecov-action@v1

View File

@@ -14,7 +14,7 @@ buildscript {
kotlin_version = '1.3.72'
// test
jacoco_tool_version = '0.8.6'
jacocoToolVersion = '0.8.6'
junitPlatformVersion = '1.7.0'
jupiterVersion = '5.7.0'
spek2Version = '2.0.12'
@@ -67,23 +67,22 @@ buildscript {
sourceProjects:
(subprojects - toolProjectsFun).findAll {
!it.name.endsWith("-js") &&
!it.name.endsWith("-android") &&
// would have two classes with the same name if we add it as project as well,
// (clashes with "${project.name}-translations-en_GB-jvm"
it.name != "${rootProject.name}-translations-de_CH-common" &&
it.name != "${rootProject.name}-translations-de_CH-jvm" &&
// does not make sense to listen specs in coverage
it.name != "${rootProject.name}-spec" &&
!it.name.startsWith("${rootProject.name}-specs")
!it.name.startsWith("${rootProject.name}-specs") &&
!it.name.contains("smoke-test")
},
jacocoProjects:
(subprojects - toolProjectsFun).findAll {
!(it.projectDir.path.contains("/translations/") || it.projectDir.path.contains("\\translations\\")) &&
!it.name.endsWith("-common") &&
!it.name.endsWith("-js") &&
!it.name.endsWith("-android") &&
it.name != "${rootProject.name}-domain-api-jvm" &&
it.name != "${rootProject.name}-core-robstoll-jvm" &&
it.name != "${rootProject.name}-spec" &&
!it.name.startsWith("${rootProject.name}-specs") &&
//TODO remove with 0.17.0
it.name != "${rootProject.name}-domain-robstoll-jvm" &&
@@ -124,7 +123,7 @@ configurations {
dependencies {
// helps dependabot to recognise versions which it should update
dependabot "org.jacoco:org.jacoco.core:$jacoco_tool_version"
dependabot "org.jacoco:org.jacoco.core:$jacocoToolVersion"
dependabot "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
dependabot "org.junit.platform:junit-platform-console:$junitPlatformVersion"
dependabot "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensionsVersion"
@@ -273,7 +272,7 @@ configure(jacocoMulti.jacocoProjects + getAndroidProjects()) {
junitjacoco {
jacoco {
toolVersion = jacoco_tool_version
toolVersion = jacocoToolVersion
}
jacocoReport {

View File

@@ -2,7 +2,7 @@ apply plugin: 'kotlin'
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacoco_tool_version"
toolVersion = "$jacocoToolVersion"
}
def jacocoProjects = (jacocoMulti.jacocoProjects)

View File

@@ -1,6 +1,7 @@
import ch.tutteli.niok.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import java.nio.file.Files
import java.nio.file.Paths
@@ -25,6 +26,7 @@ val jupiterVersion: String by rootProject.extra
val mockkVersion: String by rootProject.extra
val junitPlatformVersion: String by rootProject.extra
val spek2Version: String by rootProject.extra
val jacocoToolVersion: String by rootProject.extra
description =
"Checks that specs from older versions of Atrium can still be run with the components of the current version."
@@ -139,8 +141,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
}
configure(listOf(project(":bc-tests:$oldVersion-specs"))) {
the<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>().apply {
the<KotlinMultiplatformExtension>().apply {
jvm()
// TODO 0.16.0 reactivate once we have transition everything to the new MPP plugin
// js().nodejs {}
@@ -157,8 +158,6 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
// required by specs
//might be we have to switch to api as we have defined some of the modules as api in atrium-specs
implementation(project(":atrium-fluent-en_GB-common"))
// runtimeOnly(kotlin("stdlib-jdk8"))
}
}
val jvmMain by getting {
@@ -203,8 +202,12 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
}
apis.forEach { (apiName, targets) ->
configure(listOf(project(":bc-tests:$oldVersion-api-$apiName"))) {
the<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>().apply {
apply(plugin = "jacoco")
the<KotlinMultiplatformExtension>().apply {
// TODO 0.16.0 reactivate once we have transition everything to the new MPP plugin
// js().nodejs {}
jvm {
@@ -218,6 +221,67 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
}
}
fun createJacocoReportTask(
prefix: String,
runTaskProvider: TaskProvider<JavaExec>
): TaskProvider<JacocoReport> {
val runTask = runTaskProvider.get()
val jacocoReport = tasks.register<JacocoReport>("jacoco-$prefix-$oldVersion-$apiName") {
group = "report"
dependsOn(runTaskProvider)
executionData(runTask)
val jacocoMulti: Map<String, Iterable<Project>> by rootProject.extra
val sourceProjects = jacocoMulti["sourceProjects"]!!
val projects = when (apiName) {
"fluent-en_GB" -> sourceProjects.filter { !it.name.contains("infix-en_GB") }
"infix-en_GB" -> {
sourceProjects.filter {
!it.name.contains("translations-en_GB") &&
!it.name.contains("fluent-en_GB")
} + listOf(
project(":atrium-translations-de_CH-jvm"),
project(":atrium-translations-de_CH-common")
)
}
else -> throw IllegalStateException("re-adjust jacoco task")
}
projects.forEach {
//TODO 0.16.0 simplify once all project use new MPP plugin
val sourceSetContainer = it.extensions.findByType<SourceSetContainer>()
if (sourceSetContainer != null) {
sourceSets(sourceSetContainer["main"])
} else {
it.the<KotlinMultiplatformExtension>().sourceSets.forEach { kotlinSourceSet ->
sourceDirectories.from(kotlinSourceSet.kotlin.srcDirs)
}
}
}
// DEBUG sourceDirectories
// println("list $oldVersion $apiName: ${sourceDirectories.map { it.absolutePath }.joinToString("\n")}\n")
reports {
csv.isEnabled = false
xml.isEnabled = true
xml.destination = file("${buildDir}/reports/jacoco/$name/report.xml")
html.isEnabled = true
html.destination = file("${buildDir}/reports/jacoco/$name/html/")
}
}
the<JacocoPluginExtension>().apply {
toolVersion = jacocoToolVersion
this.applyTo<JavaExec>(runTask)
}
runTaskProvider.configure {
finalizedBy(jacocoReport)
}
return jacocoReport
}
val bcTest = tasks.register<JavaExec>("bc-$oldVersion-$apiName") {
group = "verification"
description =
@@ -233,8 +297,10 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
classpath = compilations["test"].runtimeDependencyFiles
main = "org.junit.platform.console.ConsoleLauncher"
args = getConsoleLauncherArgs(compilations["test"].output.classesDirs.asPath, forgivePattern)
args =
getConsoleLauncherArgs(compilations["test"].output.classesDirs.asPath, forgivePattern)
}
createJacocoReportTask("bc", bcTest)
bcTests.configure {
dependsOn(bcTest)
}
@@ -293,6 +359,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
main = "org.junit.platform.console.ConsoleLauncher"
args = getConsoleLauncherArgs(configurations[bbcConfName].asPath, forgivePattern)
}
createJacocoReportTask("bbc", bcTest)
bbcTests.configure {
dependsOn(bbcTest)
}
@@ -303,7 +370,15 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
val commonTest by getting {
dependencies {
implementation(project(":atrium-api-$apiName-common"))
implementation(project(":bc-tests:$oldVersion-specs"))
implementation(project(":bc-tests:$oldVersion-specs")) {
if (apiName == "infix-en_GB") {
exclude(module = "${rootProject.name}-translations-en_GB-common")
exclude(module = "${rootProject.name}-translations-en_GB-jvm")
}
}
if (apiName == "infix-en_GB") {
implementation(project(":atrium-translations-de_CH-common"))
}
// for samples
implementation(kotlin("test-common"))
@@ -314,6 +389,9 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
dependencies {
implementation(project(":atrium-api-$apiName-jvm"))
if (apiName == "infix-en_GB") {
implementation(project(":atrium-translations-de_CH-jvm"))
}
// to run forgiving spek tests
runtimeOnly(project(":bc-tests:test-engine"))
@@ -503,3 +581,4 @@ with(project(":bc-tests:0.15.0-api-infix-en_GB")) {
}
}
}