Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
- made CoverageEngineVariant internal
- improved docs and comments
- improved deprecation comments
- changed includes to excludes in projects filter for merged reports
  • Loading branch information
shanshin committed Jul 27, 2022
1 parent a2ce0f2 commit 089df8b
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -376,7 +376,7 @@ koverMerged {
}

projects { // common projects filter for all default Kover merged tasks
includes += listOf("project1", ":child:project") // Specifies the projects involved in the merged tasks
excludes += listOf("project1", ":child:project") // Specifies the projects excluded from the merged tasks
}
}

Expand Down Expand Up @@ -437,7 +437,7 @@ koverMerged {
}
projects { // common projects filter for all default Kover merged tasks
includes.addAll("project1", ":child:project") // Specifies the projects involved in the merged tasks
excludes.addAll("project1", ":child:project") // Specifies the projects excluded in the merged tasks
}
}
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.*

plugins {
kotlin("jvm") version "1.7.10"

Expand All @@ -19,6 +21,11 @@ sourceSets {
}
}

// adding the ability to use internal classes inside functional tests
kotlin.target.compilations.run {
getByName("functionalTest").associateWith(getByName(KotlinCompilation.MAIN_COMPILATION_NAME))
}

dependencies {
implementation(gradleApi())
// exclude transitive dependency on stdlib, the Gradle version should be used
Expand Down
134 changes: 117 additions & 17 deletions docs/migration-to-0.6.0.md
Expand Up @@ -22,10 +22,30 @@ To configure merged reports, the `koverMerged { }` project extension is used.

### type of `isDisabled` property changed from `Boolean` to `Property<Boolean>`.

for Kotlin script: change `isDisabled = true` to `isDisabled.set(true)`
_Error message_

```
Val cannot be reassigned
```

_Solution for Kotlin script:_ change `isDisabled = true` to `isDisabled.set(true)`

### Properties `coverageEngine`, `intellijEngineVersion` and `jacocoEngineVersion` were removed.

_Error messages:_

```
Using 'coverageEngine: Property<CoverageEngine>' is an error
```
```
Using 'intellijEngineVersion: Property<String>' is an error
```
```
Using 'jacocoEngineVersion: Property<String>' is an error
```

_Solution:_

Use property `engine` - it combines version and coverage engine vendor.

To use IntelliJ Coverage Engine with default version write `engine.set(kotlinx.kover.api.DefaultIntellijEngine)`
Expand Down Expand Up @@ -62,14 +82,21 @@ kover {

### property `disabledProjects` was removed

Use inclusion list in project filters
_Error message:_

```Using 'disabledProjects: Set<String>' is an error.```

_Solution_

- read about [merged reports changes](#foo)
- use exclusion list in project filters of merged configuration extension

```
koverMerged {
enable()
filters {
projects {
includes.add(":path or unique project name")
excludes.add(":path or unique project name")
}
}
}
Expand All @@ -88,21 +115,24 @@ TBD

## Kover extension for test task

### type of `isDisabled` property changed from "Boolean" to `Property<Boolean>`".
### type of `isDisabled` property changed from `Boolean` to `Property<Boolean>`.
_Error message_

```
Val cannot be reassigned
```

Solution for Kotlin script: change `isDisabled = true` to `isDisabled.set(true)`
_Solution for Kotlin script:_ change `isDisabled = true` to `isDisabled.set(true)`

### `binaryReportFile` was renamed to `reportFile`

Solution: change `binaryReportFile` to `reportFile`

### Type of `includes` property changed from `List<String>` to `ListProperty<String>`

Solution for Kotlin: change `includes = listOf("com.example.*", "foo.bar.*")`
to `includes.addAll("com.example.*", "foo.bar.*")`
Solution:

Solution for Groovy: change `includes = ["com.example.*", "foo.bar.*"]`
to `includes.addAll("com.example.*", "foo.bar.*")`
```includes.addAll("com.example.*", "foo.bar.*")```

### type of `excludes` property changed from `List<String>` to `ListProperty<String>`

Expand Down Expand Up @@ -180,11 +210,54 @@ kover {
```
&ast; for `xmlReportFile` task use `koverMerged { ... }` extension of the project.

## `KoverTaskExtension` configuration

### Type of `excludes` and `includes` property changed from `List<String>` to `ListProperty<String>`
_Error message:_
```
Val cannot be reassigned
```

_Solution:_

```
includes.addAll("com.example.*", "foo.bar.*")
```
and
```
excludes.addAll("com.example.*", "foo.bar.*")
```


## `koverHtmlReport` and `koverMergedHtmlReport` tasks configuration

### Class `KoverHtmlReportTask` was removed

_Error message:_
```
Using 'KoverHtmlReportTask' is an error
```

_Solution:_

Configure report by Kover project extension

```
kover {
htmlReport {
// HTML report settings
}
}
```

### Property `htmlReportDir` was removed

Solution: use property in Kover extension at the root of the project
_Error message:_
```
Using 'htmlReportDir: DirectoryProperty' is an error
```

Solution: use property `reportDir` in Kover extension at the root of the project

```
kover {
Expand All @@ -197,7 +270,12 @@ kover {

### Property `includes` was removed

Solution for Kotlin: use filter in Kover extension at the root of the project
_Error message:_
```
Using 'includes: List<String>' is an error
```

_Solution for Kotlin:_ use filter in Kover extension at the root of the project

```
kover {
Expand All @@ -209,7 +287,7 @@ kover {
}
```

Solution for Groovy: use filter in Kover extension at the root of the project
_Solution for Groovy:_ use filter in Kover extension at the root of the project

```
kover {
Expand All @@ -224,7 +302,12 @@ kover {

### Property `excludes` was removed

Solution for Kotlin: use filter in Kover extension at the root of the project
Error message:
```
Using 'excludes: List<String>' is an error
```

_Solution for Kotlin:_ use filter in Kover extension at the root of the project

```
kover {
Expand All @@ -251,9 +334,16 @@ kover {

## `koverVerify` and `koverMergedVerify` tasks configuration

### Function `rule` was removed
### Function `rule` was removed for single-project verification

Error message:
```
Using 'rule(Action<VerificationRule>): Unit' is an error
```

_Solution:_

Solution: use function in Kover extension at the root of the project
use function `rule` in Kover project extension

```
kover {
Expand All @@ -269,6 +359,11 @@ kover {

### Property `includes` was removed

_Error message:_
```
Using 'includes: List<String>' is an error
```

Solution for Kotlin: use filter in Kover extension at the root of the project

```
Expand Down Expand Up @@ -296,7 +391,12 @@ kover {

### Property `excludes` was removed

Solution for Kotlin: use filter in Kover extension at the root of the project
_Error message:_
```
Using 'excludes: List<String>' is an error
```

_Solution for Kotlin:_ use filter in Kover extension at the root of the project

```
kover {
Expand All @@ -308,7 +408,7 @@ kover {
}
```

Solution for Groovy: use filter in Kover extension at the root of the project
_Solution for Groovy:_ use filter in Kover extension at the root of the project

```
kover {
Expand Down
Expand Up @@ -138,7 +138,7 @@ internal class MultiProjectTests : BaseGradleScriptTest() {
}

@Test
fun testIncludeProject() {
fun testExcludeProject() {
val build = diverseBuild(engines = ALL_ENGINES, types = ALL_TYPES)
val subPath = build.addKoverSubproject(subprojectName) {
sourcesFrom("multiproject-common")
Expand All @@ -152,7 +152,7 @@ internal class MultiProjectTests : BaseGradleScriptTest() {
enable()
filters {
projects {
includes += rootName
excludes += subprojectName
}
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@ internal class MultiProjectTests : BaseGradleScriptTest() {
}

@Test
fun testIncludeProjectByPath() {
fun testExcludeProjectByPath() {
val build = diverseBuild(engines = ALL_ENGINES, types = ALL_TYPES)
val subPath = build.addKoverSubproject(subprojectName) {
sourcesFrom("multiproject-common")
Expand All @@ -194,7 +194,7 @@ internal class MultiProjectTests : BaseGradleScriptTest() {
enable()
filters {
projects {
includes += ":"
excludes += subPath
}
}
}
Expand Down
@@ -1,3 +1,6 @@
/*
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.kover.test.functional.cases.counters

import kotlinx.kover.api.*
Expand Down
@@ -1,3 +1,7 @@
/*
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.kover.test.functional.cases.utils

import kotlinx.kover.api.*
Expand Down
@@ -1,3 +1,7 @@
/*
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package kotlinx.kover.test.functional.core

import kotlinx.kover.api.*
Expand Down
Expand Up @@ -37,8 +37,8 @@ private fun PrintWriter.printFilters(state: TestKoverMergedFiltersState, slice:

if (projects != null) {
indented(indents + 1, "projects {")
if (projects.includes.isNotEmpty()) {
indented(indents + 2, "includes".addAllList(projects.includes, slice.language))
if (projects.excludes.isNotEmpty()) {
indented(indents + 2, "excludes".addAllList(projects.excludes, slice.language))
}
indented(indents + 1, "}")
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/kotlinx/kover/api/CoverageEngines.kt
Expand Up @@ -10,9 +10,9 @@ import org.gradle.api.tasks.*

public sealed class CoverageEngineVariant(
@get:Input
public val vendor: CoverageEngineVendor,
internal val vendor: CoverageEngineVendor,
@get:Input
public val version: String
internal val version: String
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand All @@ -37,7 +37,7 @@ public sealed class CoverageEngineVariant(
}
}

public enum class CoverageEngineVendor {
internal enum class CoverageEngineVendor {
INTELLIJ,
JACOCO
}
Expand Down

0 comments on commit 089df8b

Please sign in to comment.