85 lines
2.5 KiB
Groovy
85 lines
2.5 KiB
Groovy
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
|
|
|
plugins {
|
|
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 compile
|
|
attributes {
|
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, KotlinUsages.KOTLIN_RUNTIME))
|
|
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile project(':kotlin-test:kotlin-test-js')
|
|
}
|
|
|
|
// package.json contains direct links to the builddir
|
|
buildDir = "$projectDir/build"
|
|
|
|
[compileKotlin2Js, compileTestKotlin2Js]*.configure {
|
|
kotlinOptions.moduleKind = "commonjs"
|
|
}
|
|
|
|
task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
|
|
from compileKotlin2Js.destinationDir
|
|
dependsOn(configurations.nodeModules)
|
|
|
|
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.create("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")
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
['Jest', 'Jasmine', 'Mocha', 'Qunit', 'Tape'].each {
|
|
check.dependsOn createFrameworkTest(it)
|
|
} |