[kotlin-test] Migrate integration tests project from deprecated K/JS plugin

This commit is contained in:
Ilya Gorbunov
2024-01-17 17:57:05 +01:00
committed by Space Team
parent 000db0bb44
commit 72528056fb
+15 -35
View File
@@ -1,17 +1,14 @@
import com.github.gradle.node.npm.task.NpmTask import com.github.gradle.node.npm.task.NpmTask
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
import java.io.FileOutputStream import java.io.FileOutputStream
plugins { plugins {
kotlin("js") kotlin("multiplatform")
alias(libs.plugins.gradle.node) alias(libs.plugins.gradle.node)
idea idea
} }
description = "Kotlin-test integration tests for JS IR" description = "Kotlin-test integration tests for JS"
node { node {
version.set(nodejsVersion) version.set(nodejsVersion)
@@ -22,10 +19,8 @@ idea {
module.excludeDirs.add(file("node_modules")) module.excludeDirs.add(file("node_modules"))
} }
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
kotlin { kotlin {
js(IR) { js {
nodejs { nodejs {
testTask { testTask {
enabled = false enabled = false
@@ -34,17 +29,18 @@ kotlin {
} }
sourceSets { sourceSets {
val jsMain by getting {
} kotlin.srcDir("src/main/kotlin")
} dependencies {
implementation(project(":kotlin-stdlib"))
val nodeModules by configurations.registering { }
extendsFrom(configurations["api"]) }
attributes { val jsTest by getting {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY)) kotlin.srcDir("src/test/kotlin")
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME)) dependencies {
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js) implementation(project(":kotlin-test"))
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir) }
}
} }
} }
@@ -54,19 +50,8 @@ val compileTestDevelopmentExecutableKotlinJs = tasks.named<KotlinJsIrLink>("comp
val populateNodeModules = tasks.register<Copy>("populateNodeModules") { val populateNodeModules = tasks.register<Copy>("populateNodeModules") {
dependsOn("compileTestDevelopmentExecutableKotlinJs") dependsOn("compileTestDevelopmentExecutableKotlinJs")
dependsOn(nodeModules)
from(compileTestDevelopmentExecutableKotlinJs.map { it.destinationDirectory }) from(compileTestDevelopmentExecutableKotlinJs.map { it.destinationDirectory })
from {
nodeModules.get().map {
// WORKAROUND: Some JS IR jars were absent and caused this task to fail.
// They don't contain .js thus we can skip them.
if (it.exists()) {
zipTree(it.absolutePath).matching { include("*.js") }
} else it
}
}
into(layout.buildDirectory.dir("node_modules")) into(layout.buildDirectory.dir("node_modules"))
} }
@@ -116,8 +101,3 @@ val frameworkTests = listOf(
tasks.check { tasks.check {
frameworkTests.forEach { dependsOn(it) } frameworkTests.forEach { dependsOn(it) }
} }
dependencies {
api(project(":kotlin-test"))
}