From e4a1ece24e3b6462e2a8da99c7b294f0b1c4263f Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 22 Sep 2025 18:23:08 +0200 Subject: [PATCH 1/2] build: Introduce the Kotest property testing dependency See [1]. Going forward, as an experiment some tests will be converted to use arbitrary (reflective) values [2] where no fixed empty / dummy values are strictly needed, to emphasize the invariance on those inputs. [1]: https://kotest.io/docs/proptest/property-based-testing.html [2]: https://kotest.io/docs/proptest/reflective-arbs.html Signed-off-by: Sebastian Schuberth --- buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts | 1 + gradle/libs.versions.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts index 18a9a20bcaa37..9a2a466e7d9a5 100644 --- a/buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts @@ -61,6 +61,7 @@ testing { implementation(project(":utils:test-utils")) implementation(libs.kotest.assertions.core) + implementation(libs.kotest.property) implementation(libs.kotest.runner.junit5) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 72100c47b67ca..c0323e27a2afe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -133,6 +133,7 @@ kotest-extensions = { module = "io.kotest:kotest-extensions", version.ref = "kot kotest-extensions-junitXml = { module = "io.kotest:kotest-extensions-junitxml", version.ref = "kotest" } kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } +kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" } kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinPoet"} kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinPoet"} From 96c0cb39b6d95cbc966eb21f496b2cf3ac3dc5bd Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 22 Sep 2025 18:31:53 +0200 Subject: [PATCH 2/2] test(composer): Avoid relying on the current test directory Emphasize that the `File` argument does not matter for the test by using an arbitrary value instead. Signed-off-by: Sebastian Schuberth --- .../composer/src/funTest/kotlin/ComposerFunTest.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/package-managers/composer/src/funTest/kotlin/ComposerFunTest.kt b/plugins/package-managers/composer/src/funTest/kotlin/ComposerFunTest.kt index 05263066ba6eb..c708c72392720 100644 --- a/plugins/package-managers/composer/src/funTest/kotlin/ComposerFunTest.kt +++ b/plugins/package-managers/composer/src/funTest/kotlin/ComposerFunTest.kt @@ -26,6 +26,9 @@ import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.string.haveSubstring +import io.kotest.property.Arb +import io.kotest.property.arbitrary.file +import io.kotest.property.arbitrary.single import java.io.File @@ -39,7 +42,7 @@ import org.ossreviewtoolkit.utils.test.matchExpectedResult class ComposerFunTest : StringSpec({ "Project files from vendor directories are ignored" { val projectFiles = ComposerFactory.create().mapDefinitionFiles( - File("."), + Arb.file().single(), listOf( "projectA/composer.json", "projectA/vendor/dependency1/composer.json",