Switch stdlib tests to KMP kotlin-test KT-61969

This commit is contained in:
Ilya Gorbunov
2023-11-24 05:16:58 +01:00
committed by Space Team
parent 7a4335b087
commit f07bf70aa7
5 changed files with 38 additions and 21 deletions
+5 -17
View File
@@ -15,7 +15,7 @@ import plugins.publishing.*
import kotlin.io.path.copyTo
plugins {
id("kotlin-multiplatform")
kotlin("multiplatform")
`maven-publish`
signing
}
@@ -299,11 +299,7 @@ kotlin {
}
commonTest {
dependencies {
// TODO: use project dependency when kotlin-test is migrated
compileOnly("org.jetbrains.kotlin:kotlin-test-common:$bootstrapKotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-test-annotations-common:$bootstrapKotlinVersion")
// compileOnly(project(":kotlin-test:kotlin-test-common"))
// compileOnly(project(":kotlin-test:kotlin-test-annotations-common"))
api(kotlinTest())
}
kotlin {
srcDir("common/test")
@@ -340,7 +336,7 @@ kotlin {
optIn("kotlin.io.path.ExperimentalPathApi")
}
dependencies {
api(project(":kotlin-test:kotlin-test-junit"))
api(kotlinTest("junit"))
}
kotlin.srcDir("jvm/test")
kotlin.srcDir("jdk7/test")
@@ -349,7 +345,7 @@ kotlin {
val jvmLongRunningTest by getting {
dependencies {
api(project(":kotlin-test:kotlin-test-junit"))
api(kotlinTest("junit"))
}
kotlin.srcDir("jvm/testLongRunning")
}
@@ -416,9 +412,6 @@ kotlin {
}
}
val jsTest by getting {
dependencies {
api(project(":kotlin-test:kotlin-test-js-ir"))
}
kotlin.srcDir("${jsDir}/test")
}
@@ -493,9 +486,6 @@ kotlin {
}
val wasmJsTest by getting {
dependsOn(wasmCommonTest)
dependencies {
api(project(":kotlin-test:kotlin-test-wasm-js"))
}
kotlin {
srcDir("wasm/js/test")
}
@@ -512,9 +502,6 @@ kotlin {
}
val wasmWasiTest by getting {
dependsOn(wasmCommonTest)
dependencies {
api(project(":kotlin-test:kotlin-test-wasm-wasi"))
}
kotlin {
srcDir("wasm/wasi/test")
}
@@ -724,6 +711,7 @@ tasks {
}
val jvmLongRunningTest by registering(Test::class) {
group = "verification"
val compilation = kotlin.jvm().compilations["longRunningTest"]
classpath = compilation.compileDependencyFiles + compilation.runtimeDependencyFiles + compilation.output.allOutputs
testClassesDirs = compilation.output.classesDirs
-1
View File
@@ -26,7 +26,6 @@ sourceSets {
dependencies {
api project(':kotlin-stdlib')
testApi project(':kotlin-test:kotlin-test-junit')
}
jar {
+1 -2
View File
@@ -9,7 +9,6 @@ RepoArtifacts.javadocJar(project)
dependencies {
api project(':kotlin-stdlib')
api project(':kotlin-stdlib-jdk7')
testApi project(':kotlin-test:kotlin-test-junit')
}
sourceSets {
@@ -37,7 +36,7 @@ dependencies {
moduleTestApi project(':kotlin-stdlib')
moduleTestApi project(':kotlin-stdlib-jdk7')
moduleTestCompileOnly project
moduleTestApi project(':kotlin-test:kotlin-test-junit')
moduleTestApi RepoDependencies.kotlinTest(project, "junit")
moduleTestApi "org.ow2.asm:asm:9.0"
}
+1 -1
View File
@@ -2,7 +2,7 @@ apply plugin: 'kotlin'
dependencies {
api project(':kotlin-stdlib-jdk8')
testApi project(':kotlin-test:kotlin-test-junit')
testApi RepoDependencies.kotlinTest(project, "junit")
}
sourceSets {
@@ -61,6 +61,37 @@ fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): An
dependencies.project(listOfNotNull(":kotlin-stdlib", suffix).joinToString("-"), classifier)
}
/**
* Use this function to declare a dependency on kotlin-test project artifacts.
*
* It creates either a project dependency or a binary dependency on bootstrap artifacts when JPS build is imported.
*
* @param suffix Supported suffixes are:
* - `null` for the default project dependency, variant is resolved by attributes
* - `junit`, `junit5`, `testng` - jvm variants with annotation typealiases for different test frameworks,
* - `js` - js variant with assertions and annotations
* @param classifier Supported classifiers are: `null` for the runtime artifact, `sources` for the sources jar artifact
*/
@JvmOverloads
fun Project.kotlinTest(suffix: String? = null, classifier: String? = null): Any {
return run {
val elementsType = when (classifier) {
null -> "Runtime"
"sources" -> "Sources"
else -> error("Unsupported kotlin-test classifier: $classifier")
}
val configuration = when (suffix?.lowercase()) {
null -> classifier?.let { "jvm${elementsType}Elements" }
"junit" -> "jvmJUnit${elementsType}Elements"
"junit5" -> "jvmJUnit5${elementsType}Elements"
"testng" -> "jvmTestNG${elementsType}Elements"
"js" -> "js${elementsType}Elements"
else -> error("Unsupported kotlin-test flavor: $suffix")
}
dependencies.project(":kotlin-test", configuration)
}
}
fun Project.kotlinBuiltins(): Any = kotlinBuiltins(forJvm = false)
fun Project.kotlinBuiltins(forJvm: Boolean): Any =