Skip to content

Commit e557722

Browse files
authored
Add kotest-assertions to common test dependencies (#445)
* Add kotest assertions to common test dependencies * Start using them in some tests * Remove duplicated conversion to sequence Part of #408
1 parent 101ce22 commit e557722

6 files changed

Lines changed: 16 additions & 7 deletions

File tree

buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/kotlin-library.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ kotlin {
6868
languageSettings.optIn("kotlin.RequiresOptIn")
6969
}
7070
val commonMain by getting
71-
val commonTest by getting
71+
val commonTest by getting {
72+
dependencies {
73+
implementation("io.kotest:kotest-assertions-core:5.3.0")
74+
}
75+
}
7276
val commonNonJsMain by creating {
7377
dependsOn(commonMain)
7478
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ junit = "5.9.1"
1010
ktoml = "0.3.0"
1111
multiplatform-diff = "0.4.0"
1212
kotlinpoet = "1.12.0"
13+
kotest = "5.3.0"
1314
sarif4k = "0.3.0"
1415

1516
[plugins]
@@ -34,4 +35,5 @@ ktoml-file = { module = "com.akuleshov7:ktoml-file", version.ref = "ktoml" }
3435
multiplatform-diff = { module = "io.github.petertrr:kotlin-multiplatform-diff", version.ref = "multiplatform-diff" }
3536
square-kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
3637
diktat-gradle-plugin = { module = "org.cqfn.diktat:diktat-gradle-plugin", version.ref = "diktat" }
37-
sarif4k = { module = "io.github.detekt.sarif4k:sarif4k", version.ref = "sarif4k" }
38+
sarif4k = { module = "io.github.detekt.sarif4k:sarif4k", version.ref = "sarif4k" }
39+
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }

save-common/src/commonMain/kotlin/com/saveourtool/save/core/plugin/ExtraFlagsExtractor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ internal fun List<String>.filterAndJoinBy(regex: Regex, ending: Char): List<Stri
7272

7373
/**
7474
* Split [this] string by [delimiter] unless it's prepended by `\`.
75+
* fixme: allow escaping of slashes, i.e. `\\,` shouldn't lead to splitting.
7576
*
7677
* @param delimiter
7778
* @return list of string parts

save-core/src/commonNonJsTest/kotlin/com/saveourtool/save/core/integration/WarnDirTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.saveourtool.save.core.integration
22

33
import com.saveourtool.save.core.test.utils.runTestsWithDiktat
4+
import io.kotest.matchers.collections.exist
5+
import io.kotest.matchers.shouldNot
46

57
import kotlin.test.Ignore
68
import kotlin.test.Test
7-
import kotlin.test.assertTrue
89

910
@Ignore // https://github.com/saveourtool/save-cli/issues/402
1011
class WarnDirTest {
@@ -31,8 +32,8 @@ class WarnDirTest {
3132
@Test
3233
fun `execute warn plugin on root directory`() {
3334
val reporter = runTestsWithDiktat(listOf("warn-dir"), 6)
34-
reporter.results.forEach { testResult ->
35-
assertTrue(!testResult.debugInfo!!.execCmd!!.contains("chapter"))
35+
reporter.results shouldNot exist { testResult ->
36+
testResult.debugInfo!!.execCmd!!.contains("chapter")
3637
}
3738
}
3839
}

save-core/src/commonNonJsTest/kotlin/com/saveourtool/save/core/test/utils/TestUtilsCommon.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.saveourtool.save.core.result.Fail
1717
import com.saveourtool.save.core.result.Ignored
1818
import com.saveourtool.save.core.result.Pass
1919
import com.saveourtool.save.reporter.test.TestReporter
20+
import io.kotest.matchers.types.shouldBeTypeOf
2021

2122
import okio.Path
2223

@@ -79,7 +80,7 @@ fun runTestsWithDiktat(
7980
if (test.status is Ignored) {
8081
assertEquals(Ignored("Excluded by configuration"), test.status)
8182
} else {
82-
assertTrue(test.status is Pass)
83+
test.status.shouldBeTypeOf<Pass>()
8384
}
8485
}
8586
}

save-plugins/warn-plugin/src/commonMain/kotlin/com/saveourtool/save/plugin/warn/WarnPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class WarnPlugin(
7979
//
8080
// In case, when user doesn't want to use directory mode, he needs simply not to pass [wildCardInDirectoryMode] and it will be null
8181
return warnPluginConfig.wildCardInDirectoryMode?.let {
82-
handleTestFile(files.map { it.test }.toList(), warnPluginConfig, generalConfig, batchSeparator).asSequence()
82+
handleTestFile(files.map { it.test }.toList(), warnPluginConfig, generalConfig, batchSeparator)
8383
} ?: run {
8484
files.chunked(batchSize).flatMap { chunk ->
8585
handleTestFile(chunk.map { it.test }, warnPluginConfig, generalConfig, batchSeparator)

0 commit comments

Comments
 (0)