-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to specify inclusion filter for source sets
Resolves #714
- Loading branch information
Showing
17 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
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
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
103 changes: 103 additions & 0 deletions
103
...unctionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/SourceSetsTests.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,103 @@ | ||
/* | ||
* Copyright 2017-2025 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.kover.gradle.plugin.test.functional.cases | ||
|
||
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.createCheckerContext | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.buildFromTemplate | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.runWithParams | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertTrue | ||
|
||
internal class SourceSetsTests { | ||
|
||
@Test | ||
fun testExclude() { | ||
val template = buildFromTemplate("sourcesets-multi") | ||
|
||
template.kover { | ||
currentProject { | ||
sources.excludedSourceSets.addAll("main", "foo") | ||
} | ||
} | ||
|
||
val gradleBuild = template.generate() | ||
val buildResult = gradleBuild.runWithParams(":koverXmlReport") | ||
|
||
gradleBuild.createCheckerContext(buildResult).xmlReport { | ||
assertTrue(buildResult.isSuccessful, "Build should be successful") | ||
classCounter("kotlinx.kover.examples.sourcesets.MainClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.FooClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.ExtraClass").assertPresent() | ||
} | ||
} | ||
|
||
@Test | ||
fun testInclude() { | ||
val template = buildFromTemplate("sourcesets-multi") | ||
|
||
template.kover { | ||
currentProject { | ||
sources.excludedOtherSourceSets.addAll("extra") | ||
} | ||
} | ||
|
||
val gradleBuild = template.generate() | ||
val buildResult = gradleBuild.runWithParams(":koverXmlReport") | ||
|
||
gradleBuild.createCheckerContext(buildResult).xmlReport { | ||
assertTrue(buildResult.isSuccessful, "Build should be successful") | ||
classCounter("kotlinx.kover.examples.sourcesets.MainClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.FooClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.ExtraClass").assertPresent() | ||
} | ||
} | ||
|
||
@Test | ||
fun testInclude2() { | ||
val template = buildFromTemplate("sourcesets-multi") | ||
|
||
template.kover { | ||
currentProject { | ||
sources.excludedOtherSourceSets.addAll("extra", "foo") | ||
} | ||
} | ||
|
||
val gradleBuild = template.generate() | ||
val buildResult = gradleBuild.runWithParams(":koverXmlReport") | ||
|
||
gradleBuild.createCheckerContext(buildResult).xmlReport { | ||
assertTrue(buildResult.isSuccessful, "Build should be successful") | ||
classCounter("kotlinx.kover.examples.sourcesets.MainClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.FooClass").assertPresent() | ||
classCounter("kotlinx.kover.examples.sourcesets.ExtraClass").assertPresent() | ||
} | ||
} | ||
|
||
@Test | ||
fun testMixed() { | ||
val template = buildFromTemplate("sourcesets-multi") | ||
|
||
template.kover { | ||
currentProject { | ||
sources { | ||
excludedOtherSourceSets.addAll("extra", "foo") | ||
excludedSourceSets.add("foo") | ||
} | ||
} | ||
} | ||
|
||
val gradleBuild = template.generate() | ||
val buildResult = gradleBuild.runWithParams(":koverXmlReport") | ||
|
||
gradleBuild.createCheckerContext(buildResult).xmlReport { | ||
assertTrue(buildResult.isSuccessful, "Build should be successful") | ||
classCounter("kotlinx.kover.examples.sourcesets.MainClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.FooClass").assertAbsent() | ||
classCounter("kotlinx.kover.examples.sourcesets.ExtraClass").assertPresent() | ||
} | ||
} | ||
|
||
|
||
} |
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
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
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
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
11 changes: 11 additions & 0 deletions
11
kover-gradle-plugin/src/functionalTest/templates/builds/sourcesets-multi/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,11 @@ | ||
plugins { | ||
kotlin("jvm") version "2.1.0" | ||
id("org.jetbrains.kotlinx.kover") version "0.7.0" | ||
} | ||
|
||
sourceSets.create("extra") | ||
sourceSets.create("foo") | ||
|
||
dependencies { | ||
testImplementation(kotlin("test")) | ||
} |
8 changes: 8 additions & 0 deletions
8
kover-gradle-plugin/src/functionalTest/templates/builds/sourcesets-multi/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,8 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
rootProject.name = "example-source-multi" | ||
|
7 changes: 7 additions & 0 deletions
7
...lugin/src/functionalTest/templates/builds/sourcesets-multi/src/extra/kotlin/ExtraClass.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 kotlinx.kover.examples.sourcesets | ||
|
||
class ExtraClass { | ||
fun function() { | ||
println("Example") | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...le-plugin/src/functionalTest/templates/builds/sourcesets-multi/src/foo/kotlin/FooClass.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 kotlinx.kover.examples.sourcesets | ||
|
||
class FooClass { | ||
fun function() { | ||
println("Example") | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...-plugin/src/functionalTest/templates/builds/sourcesets-multi/src/main/kotlin/MainClass.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 kotlinx.kover.examples.sourcesets | ||
|
||
class MainClass { | ||
fun function() { | ||
println("Example") | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...lugin/src/functionalTest/templates/builds/sourcesets-multi/src/test/kotlin/TestClasses.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 kotlinx.kover.examples.sourcesets | ||
|
||
import kotlin.test.Test | ||
|
||
class TestClasses { | ||
@Test | ||
fun test() { | ||
// no-tests | ||
} | ||
} |
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
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
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
Oops, something went wrong.