Skip to content

Commit 90da9a5

Browse files
committed
feat(cli): Create a stand-alone launcher for functional tests
The `main` function from Kotest's launcher [1] supports several options, see [2]. After running `./gradlew :cli-test-launcher:installDist`, use e.g. ``` ./cli-test-launcher/build/install/ort-test-launcher/bin/ort-test-launcher --package org.ossreviewtoolkit.plugins.packagemanagers ``` to run all package manager tests. Resolves #10025. [1]: https://github.com/kotest/kotest/blob/v5.9.1/kotest-framework/kotest-framework-engine/src/jvmMain/kotlin/io/kotest/engine/launcher/main.kt [2]: https://github.com/kotest/kotest/blob/v5.9.1/kotest-framework/kotest-framework-engine/src/jvmMain/kotlin/io/kotest/engine/launcher/parseLauncherArgs.kt Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent b027fab commit 90da9a5

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

buildSrc/src/main/kotlin/ort-kotlin-conventions.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ detekt {
104104
}
105105

106106
java {
107+
// Register functional tests as a feature of the main library, see
108+
// https://docs.gradle.org/current/userguide/how_to_create_feature_variants_of_a_library.html.
109+
registerFeature("funTest") {
110+
usingSourceSet(sourceSets["funTest"])
111+
}
112+
107113
toolchain {
108114
// Note that Gradle currently matches the Java language version exactly and does not consider (backward)
109115
// compatibility between versions, see https://github.com/gradle/gradle/issues/16256.

cli-test-launcher/build.gradle.kts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2025 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
plugins {
21+
// Apply precompiled plugins.
22+
id("ort-application-conventions")
23+
}
24+
25+
application {
26+
applicationName = "ort-test-launcher"
27+
mainClass = "io.kotest.engine.launcher.MainKt"
28+
}
29+
30+
val Project.hasFunTests
31+
// Do not dig into sourceSets to avoid coupling between projects.
32+
get() = projectDir.resolve("src/funTest").isDirectory
33+
34+
dependencies {
35+
rootProject.subprojects.filter { it.hasFunTests }.forEach {
36+
implementation(project(it.path)) {
37+
capabilities {
38+
// Note that this uses kebab-case although "registerFeature()" uses camelCase, see
39+
// https://github.com/gradle/gradle/issues/31362.
40+
@Suppress("UnstableApiUsage")
41+
requireFeature("fun-test")
42+
}
43+
}
44+
}
45+
}
46+
47+
tasks.named<Sync>("installDist") {
48+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
49+
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ include(":advisor")
2727
include(":analyzer")
2828
include(":cli")
2929
include(":cli-helper")
30+
include(":cli-test-launcher")
3031
include(":clients:bazel-module-registry")
3132
include(":clients:clearly-defined")
3233
include(":clients:dos")

0 commit comments

Comments
 (0)