Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlin Multiplatform plugin adapter rewritten to use reflection
Fixes #100
- Loading branch information
Showing
12 changed files
with
207 additions
and
29 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/AdaptersTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kotlinx.kover.test.functional.cases | ||
|
||
import kotlinx.kover.test.functional.cases.utils.assertCounterFullyCovered | ||
import kotlinx.kover.test.functional.cases.utils.defaultXmlModuleReport | ||
import kotlinx.kover.test.functional.cases.utils.defaultXmlReport | ||
import kotlinx.kover.test.functional.core.BaseGradleScriptTest | ||
import kotlin.test.* | ||
|
||
internal class AdaptersTests : BaseGradleScriptTest() { | ||
@Test | ||
fun testSubmoduleHasAnotherPlugin() { | ||
/* | ||
Tests for https://github.com/Kotlin/kotlinx-kover/issues/100 | ||
Classes from plugins applied in submodule not accessible for Kover in root module. | ||
Therefore, Kover is forced to use reflection to work with extensions of the kotlin multiplatform plugin. | ||
*/ | ||
internalProject("different-plugins") | ||
.run("koverXmlReport") { | ||
xml(defaultXmlReport()) { | ||
assertCounterFullyCovered(classCounter("org.jetbrains.CommonClass")) | ||
assertCounterFullyCovered(classCounter("org.jetbrains.JvmClass")) | ||
} | ||
} | ||
|
||
internalProject("different-plugins") | ||
.run("koverXmlModuleReport") { | ||
submodule("submodule-multiplatform") { | ||
xml(defaultXmlModuleReport()) { | ||
assertCounterFullyCovered(classCounter("org.jetbrains.CommonClass")) | ||
assertCounterFullyCovered(classCounter("org.jetbrains.JvmClass")) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/functionalTest/kotlin/kotlinx/kover/test/functional/core/Loader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package kotlinx.kover.test.functional.core | ||
|
||
import java.io.* | ||
|
||
private const val INTERNAL_PROJECTS_PATH = "src/functionalTest/templates/projects" | ||
|
||
|
||
internal fun loadInternalProject(name: String, rootDir: File): ProjectRunner { | ||
val targetDir = File.createTempFile(name, null, rootDir) | ||
|
||
val srcDir = File(INTERNAL_PROJECTS_PATH, name) | ||
if (!srcDir.exists()) { | ||
throw IllegalArgumentException("Internal test project '$name' not found") | ||
} | ||
|
||
srcDir.copyRecursively(targetDir, true) | ||
|
||
return SingleProjectRunnerImpl(targetDir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/functionalTest/templates/projects/different-plugins/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id("org.jetbrains.kotlinx.kover") version "DEV" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} |
3 changes: 3 additions & 0 deletions
3
src/functionalTest/templates/projects/different-plugins/settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rootProject.name = "different-plugins" | ||
|
||
include(":submodule-multiplatform") |
19 changes: 19 additions & 0 deletions
19
...ctionalTest/templates/projects/different-plugins/submodule-multiplatform/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
jvm() | ||
|
||
sourceSets { | ||
commonTest { | ||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-test") | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...s/projects/different-plugins/submodule-multiplatform/src/commonMain/kotlin/CommonClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jetbrains | ||
|
||
class CommonClass { | ||
fun function() { | ||
println("Function") | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...es/projects/different-plugins/submodule-multiplatform/src/commonTest/kotlin/CommonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.jetbrains | ||
|
||
import kotlin.test.Test | ||
|
||
class CommonTest { | ||
@Test | ||
fun testCommon() { | ||
CommonClass().function() | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...mplates/projects/different-plugins/submodule-multiplatform/src/jvmMain/kotlin/JvmClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jetbrains | ||
|
||
class JvmClass { | ||
fun jvmFunction() { | ||
println("JVM function") | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...emplates/projects/different-plugins/submodule-multiplatform/src/jvmTest/kotlin/JvmTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.jetbrains | ||
|
||
import kotlin.test.Test | ||
|
||
class JvmTest { | ||
@Test | ||
fun jvmTest() { | ||
JvmClass().jvmFunction() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters