Files
kotlin-fork/libraries/kotlin.test/js/it/build.gradle
T
Vyacheslav Gerasimov ab146bd6d4 Build: Fix deprecated Gradle configurations usages
for migration to Gradle 7+ #KTI-559
2021-09-26 18:28:44 +03:00

91 lines
2.6 KiB
Groovy

import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
plugins {
// TODO: update gradle-node-plugin to support configuration cache
id "com.github.node-gradle.node" version "2.2.0"
}
description = 'Kotlin-test integration tests for JS'
apply plugin: 'kotlin-platform-js'
configurations {
nodeModules {
extendsFrom api
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
}
}
}
dependencies {
api project(':kotlin-test:kotlin-test-js')
}
// package.json contains direct links to the builddir
buildDir = "$projectDir/build"
["compileKotlin2Js", "compileTestKotlin2Js"].forEach {
tasks.named(it).configure {
kotlinOptions.moduleKind = "commonjs"
}
}
tasks.register("populateNodeModules", Copy) {
dependsOn(compileKotlin2Js)
dependsOn(configurations.nodeModules)
from compileKotlin2Js.destinationDir
from {
configurations.nodeModules.collect {
// 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' }
}
}
}
into "${buildDir}/node_modules"
}
node {
version = '12.18.0'
download = true
}
def createFrameworkTest(def name) {
return tasks.register("test$name", NpmTask) {
dependsOn(compileTestKotlin2Js, populateNodeModules, npmInstall)
def lowerName = name.toLowerCase()
def tcOutput = "$buildDir/tc-${lowerName}.log"
def stdOutput = "$buildDir/test-${lowerName}.log"
def errOutput = "$buildDir/test-${lowerName}.err.log"
inputs.files(sourceSets.test.output)
inputs.dir("${buildDir}/node_modules")
outputs.files(tcOutput, stdOutput, errOutput)
args = ['run', "test-$lowerName"]
group = 'verification'
execOverrides {
it.ignoreExitValue = true
it.standardOutput = new FileOutputStream(stdOutput)
it.errorOutput = new FileOutputStream(errOutput)
}
doLast {
println file(tcOutput).text
if (result.exitValue != 0 && !rootProject.ignoreTestFailures) {
throw new GradleException("$name integration test failed")
}
}
}
}
tasks.check {
['Jest', 'Jasmine', 'Mocha', 'Qunit', 'Tape'].each {
dependsOn createFrameworkTest(it)
}
}