Skip to content

Commit

Permalink
Defined test report extension in the report-vendor enum
Browse files Browse the repository at this point in the history
Thanks!
  • Loading branch information
aSemy committed Aug 29, 2022
1 parent 767350c commit 0181158
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Expand Up @@ -7,7 +7,7 @@ package kotlinx.kover.test.functional.cases.utils
import kotlinx.kover.test.functional.core.ProjectType


internal fun defaultTestTask(projectType: ProjectType): String {
internal fun defaultTestTaskName(projectType: ProjectType): String {
return when (projectType) {
ProjectType.KOTLIN_JVM -> "test"
ProjectType.KOTLIN_MULTIPLATFORM -> "jvmTest"
Expand Down
Expand Up @@ -99,8 +99,9 @@ private class RunResultImpl(

override val defaultBinaryReport: String
get() {
val extension = if (engineVendor == CoverageEngineVendor.JACOCO) "exec" else "ic"
return binaryReportsDirectory() + "/" + defaultTestTask(slice?.type ?: ProjectType.KOTLIN_JVM) + "." + extension
val testTaskName = defaultTestTaskName(slice?.type ?: ProjectType.KOTLIN_JVM)
val extension = engineVendor.reportFileExtension
return "${binaryReportsDirectory()}/$testTaskName.$extension"
}

// IntelliJ is a default Engine
Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/kotlinx/kover/api/CoverageEngines.kt
Expand Up @@ -37,9 +37,14 @@ public sealed class CoverageEngineVariant(
}
}

internal enum class CoverageEngineVendor {
INTELLIJ,
JACOCO
/**
* @param[reportFileExtension] The coverage report file extension, without the first `.`
*/
internal enum class CoverageEngineVendor(
val reportFileExtension: String
) {
INTELLIJ("ic"),
JACOCO("exec"),
}

// TODO make internal in 0.7 version
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kotlinx/kover/appliers/KoverTaskApplier.kt
Expand Up @@ -62,8 +62,8 @@ private fun Task.createTaskExtension(projectExtension: KoverProjectConfig): Kove
taskExtension.isDisabled.convention(false)

val reportFile = project.layout.buildDirectory.zip(projectExtension.engine) { buildDir, engine ->
val suffix = if (engine.vendor == CoverageEngineVendor.INTELLIJ) ".ic" else ".exec"
buildDir.file("kover/$name$suffix")
val suffix = engine.vendor.reportFileExtension
buildDir.file("kover/$name.$suffix")
}

taskExtension.reportFile.convention(reportFile)
Expand Down

0 comments on commit 0181158

Please sign in to comment.