Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All filters for both engines now use only `*` and `?` wildcards. Resolves #21
- Loading branch information
Showing
23 changed files
with
656 additions
and
381 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
58 changes: 58 additions & 0 deletions
58
...unctionalTest/kotlin/kotlinx/kover/test/functional/cases/InstrumentationFilteringTests.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,58 @@ | ||
package kotlinx.kover.test.functional.cases | ||
|
||
import kotlinx.kover.api.* | ||
import kotlinx.kover.test.functional.cases.utils.* | ||
import kotlinx.kover.test.functional.core.* | ||
import kotlinx.kover.test.functional.core.BaseGradleScriptTest | ||
import kotlin.test.* | ||
|
||
internal class InstrumentationFilteringTests : BaseGradleScriptTest() { | ||
|
||
@Test | ||
fun testExclude() { | ||
builder() | ||
.case("Test exclusion of classes from instrumentation") | ||
.languages(GradleScriptLanguage.KOTLIN, GradleScriptLanguage.GROOVY) | ||
.types(ProjectType.KOTLIN_JVM, ProjectType.KOTLIN_MULTIPLATFORM) | ||
.engines(CoverageEngine.INTELLIJ, CoverageEngine.JACOCO) | ||
.sources("simple") | ||
.configTest( | ||
"""excludes = listOf("org.jetbrains.*Exa?ple*")""", | ||
"""excludes = ['org.jetbrains.*Exa?ple*']""" | ||
) | ||
.build() | ||
.run("build") { | ||
xml(DEFAULT_XML) { | ||
assertCounterExcluded(classCounter("org.jetbrains.ExampleClass"), this@run.engine) | ||
assertCounterCoveredAndIncluded(classCounter("org.jetbrains.SecondClass")) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testExcludeInclude() { | ||
builder() | ||
.case("Test inclusion and exclusion of classes in instrumentation") | ||
.languages(GradleScriptLanguage.KOTLIN, GradleScriptLanguage.GROOVY) | ||
.types(ProjectType.KOTLIN_JVM, ProjectType.KOTLIN_MULTIPLATFORM) | ||
.engines(CoverageEngine.INTELLIJ, CoverageEngine.JACOCO) | ||
.sources("simple") | ||
.configTest( | ||
"""includes = listOf("org.jetbrains.*Cla?s")""", | ||
"""includes = ['org.jetbrains.*Cla?s']""" | ||
) | ||
.configTest( | ||
"""excludes = listOf("org.jetbrains.*Exa?ple*")""", | ||
"""excludes = ['org.jetbrains.*Exa?ple*']""" | ||
) | ||
.build() | ||
.run("build") { | ||
xml(DEFAULT_XML) { | ||
assertCounterExcluded(classCounter("org.jetbrains.ExampleClass"), this@run.engine) | ||
assertCounterExcluded(classCounter("org.jetbrains.Unused"), this@run.engine) | ||
assertCounterCoveredAndIncluded(classCounter("org.jetbrains.SecondClass")) | ||
} | ||
} | ||
} | ||
|
||
} |
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
65 changes: 50 additions & 15 deletions
65
src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/utils/Commons.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 |
---|---|---|
@@ -1,38 +1,73 @@ | ||
package kotlinx.kover.test.functional.cases.utils | ||
|
||
import kotlinx.kover.api.* | ||
import kotlinx.kover.test.functional.core.* | ||
import kotlinx.kover.test.functional.core.RunResult | ||
import kotlin.test.* | ||
|
||
internal fun RunResult.checkIntellijBinaryReport(binary: String, smap: String, mustExists: Boolean = true) { | ||
if (mustExists) { | ||
assertTrue { file(binary).exists() } | ||
assertTrue { file(binary).length() > 0 } | ||
assertTrue { file(smap).exists() } | ||
assertTrue { file(smap).length() > 0 } | ||
file(binary) { | ||
assertTrue { exists() } | ||
assertTrue { length() > 0 } | ||
} | ||
file(smap) { | ||
assertTrue { exists() } | ||
assertTrue { length() > 0 } | ||
} | ||
} else { | ||
assertFalse { file(binary).exists() } | ||
assertFalse { file(smap).exists() } | ||
file(binary) { | ||
assertFalse { exists() } | ||
} | ||
file(smap) { | ||
assertFalse { exists() } | ||
} | ||
} | ||
} | ||
|
||
internal fun RunResult.checkJacocoBinaryReport(binary: String, mustExists: Boolean = true) { | ||
if (mustExists) { | ||
assertTrue { file(binary).exists() } | ||
assertTrue { file(binary).length() > 0 } | ||
file(binary) { | ||
assertTrue { exists() } | ||
assertTrue { length() > 0 } | ||
} | ||
} else { | ||
assertFalse { file(binary).exists() } | ||
file(binary) { | ||
assertFalse { exists() } | ||
} | ||
} | ||
} | ||
|
||
internal fun RunResult.checkReports(xmlPath: String, htmlPath: String, mustExists: Boolean = true) { | ||
if (mustExists) { | ||
assertTrue { file(xmlPath).exists() } | ||
assertTrue { file(xmlPath).length() > 0 } | ||
assertTrue { file(htmlPath).exists() } | ||
assertTrue { file(htmlPath).isDirectory } | ||
file(xmlPath) { | ||
assertTrue { exists() } | ||
assertTrue { length() > 0 } | ||
} | ||
file(htmlPath) { | ||
assertTrue { exists() } | ||
assertTrue { isDirectory } | ||
} | ||
} else { | ||
assertFalse { file(xmlPath).exists() } | ||
assertFalse { file(htmlPath).exists() } | ||
file(xmlPath) { | ||
assertFalse { exists() } | ||
} | ||
file(htmlPath) { | ||
assertFalse { exists() } | ||
} | ||
} | ||
} | ||
|
||
internal fun assertCounterExcluded(counter: Counter?, engine: CoverageEngine) { | ||
if (engine == CoverageEngine.INTELLIJ) { | ||
assertNull(counter) | ||
} else { | ||
assertNotNull(counter) | ||
assertEquals(0, counter.covered) | ||
} | ||
} | ||
|
||
internal fun assertCounterCoveredAndIncluded(counter: Counter?) { | ||
assertNotNull(counter) | ||
assertTrue { counter.covered > 0 } | ||
} |
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.