90c867ae1d
Consequently, it fixes the inability to run some JS related tests on Apple devices with ARM.
94 lines
2.8 KiB
Groovy
94 lines
2.8 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 "3.2.1"
|
|
}
|
|
|
|
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.destinationDirectory
|
|
|
|
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 = DependenciesKt.getNodejsVersion(project)
|
|
download = true
|
|
}
|
|
|
|
def createFrameworkTest(def name) {
|
|
return tasks.register("test$name", NpmTask) {
|
|
dependsOn(compileTestKotlin2Js, populateNodeModules, npmInstall)
|
|
def testName = name
|
|
def lowerName = name.toLowerCase()
|
|
def tcOutput = project.file("$buildDir/tc-${lowerName}.log")
|
|
def stdOutput = "$buildDir/test-${lowerName}.log"
|
|
def errOutput = "$buildDir/test-${lowerName}.err.log"
|
|
def exitCodeFile = project.file("$buildDir/test-${lowerName}.exit-code")
|
|
inputs.files(sourceSets.test.output)
|
|
inputs.dir("${buildDir}/node_modules")
|
|
outputs.files(tcOutput, stdOutput, errOutput, exitCodeFile)
|
|
|
|
args = ['run', "test-$lowerName"]
|
|
group = 'verification'
|
|
execOverrides {
|
|
it.ignoreExitValue = true
|
|
it.standardOutput = new FileOutputStream(stdOutput)
|
|
it.errorOutput = new FileOutputStream(errOutput)
|
|
}
|
|
|
|
def ignoreTestFailures = rootProject.ignoreTestFailures
|
|
doLast {
|
|
println tcOutput.text
|
|
if (exitCodeFile.text != "0" && !ignoreTestFailures) {
|
|
throw new GradleException("$testName integration test failed")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.check {
|
|
['Jest', 'Jasmine', 'Mocha', 'Qunit', 'Tape'].each {
|
|
dependsOn createFrameworkTest(it)
|
|
}
|
|
}
|