Build: Setup inputs and outputs for :js:js-tests:test task properly

All task inputs should be declared and separated from outputs produced
by it (e.g. node modules and js compile outputs) to make gradle test
distribution work
This commit is contained in:
Vyacheslav Gerasimov
2020-07-05 14:26:21 +03:00
parent d5c1e5681c
commit 0389589d83
5 changed files with 151 additions and 64 deletions
+46 -5
View File
@@ -188,14 +188,22 @@ fun Test.setUpJsBoxTests(jsEnabled: Boolean, jsIrEnabled: Boolean) {
setupV8()
dependsOn(":dist")
if (jsEnabled) dependsOn(testJsRuntime)
if (jsEnabled) {
dependsOn(testJsRuntime)
inputs.files(testJsRuntime)
}
if (jsIrEnabled) {
dependsOn(":kotlin-stdlib-js-ir:compileKotlinJs")
systemProperty("kotlin.js.full.stdlib.path", "libraries/stdlib/js-ir/build/classes/kotlin/js/main")
inputs.dir(rootDir.resolve("libraries/stdlib/js-ir/build/classes/kotlin/js/main"))
dependsOn(":kotlin-stdlib-js-ir-minimal-for-test:compileKotlinJs")
systemProperty("kotlin.js.reduced.stdlib.path", "libraries/stdlib/js-ir-minimal-for-test/build/classes/kotlin/js/main")
inputs.dir(rootDir.resolve("libraries/stdlib/js-ir-minimal-for-test/build/classes/kotlin/js/main"))
dependsOn(":kotlin-test:kotlin-test-js-ir:compileKotlinJs")
systemProperty("kotlin.js.kotlin.test.path", "libraries/kotlin.test/js-ir/build/classes/kotlin/js/main")
inputs.dir(rootDir.resolve("libraries/kotlin.test/js-ir/build/classes/kotlin/js/main"))
}
exclude("org/jetbrains/kotlin/js/test/wasm/semantics/*")
@@ -210,6 +218,8 @@ fun Test.setUpJsBoxTests(jsEnabled: Boolean, jsIrEnabled: Boolean) {
fun Test.setUpBoxTests() {
workingDir = rootDir
dependsOn(antLauncherJar)
inputs.files(antLauncherJar)
doFirst {
systemProperty("kotlin.ant.classpath", antLauncherJar.asPath)
systemProperty("kotlin.ant.launcher.class", "org.apache.tools.ant.Main")
@@ -225,8 +235,23 @@ fun Test.setUpBoxTests() {
}
}
val testDataDir = project(":js:js.translator").projectDir.resolve("testData")
projectTest(parallel = true) {
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = true)
inputs.dir(rootDir.resolve("compiler/cli/cli-common/resources")) // compiler.xml
inputs.dir(testDataDir)
inputs.dir(rootDir.resolve("dist"))
inputs.dir(rootDir.resolve("compiler/testData"))
inputs.dir(rootDir.resolve("libraries/stdlib/api/js"))
inputs.dir(rootDir.resolve("libraries/stdlib/api/js-v1"))
systemProperty("kotlin.js.test.root.out.dir", "$buildDir/")
outputs.dir("$buildDir/out")
outputs.dir("$buildDir/out-min")
outputs.dir("$buildDir/out-pir")
}
projectTest("jsTest", true) {
@@ -276,16 +301,23 @@ val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateJs
dependsOn(":compiler:generateTestData")
}
val testDataDir = project(":js:js.translator").projectDir.resolve("testData")
extensions.getByType(NodeExtension::class.java).nodeModulesDir = buildDir
extensions.getByType(NodeExtension::class.java).nodeModulesDir = testDataDir
val prepareMochaTestData by tasks.registering(Copy::class) {
from(testDataDir) {
include("package.json")
include("test.js")
}
into(buildDir)
}
val npmInstall by tasks.getting(NpmTask::class) {
setWorkingDir(testDataDir)
dependsOn(prepareMochaTestData)
setWorkingDir(buildDir)
}
val runMocha by task<NpmTask> {
setWorkingDir(testDataDir)
setWorkingDir(buildDir)
val target = if (project.hasProperty("teamcity")) "runOnTeamcity" else "test"
setArgs(listOf("run", target))
@@ -296,6 +328,15 @@ val runMocha by task<NpmTask> {
val check by tasks
check.dependsOn(this)
doFirst {
setEnvironment(
mapOf(
"KOTLIN_JS_LOCATION" to rootDir.resolve("dist/js/kotlin.js"),
"KOTLIN_JS_TEST_LOCATION" to rootDir.resolve("dist/js/kotlin-test.js")
)
)
}
}
projectTest("wasmTest", true) {