2023-01-03 06:29:13 -08:00
|
|
|
/*
|
|
|
|
* Copyright 2023 Alexey Andreev.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
`java-library`
|
|
|
|
}
|
|
|
|
|
|
|
|
description = "Tests"
|
|
|
|
|
2023-02-01 09:40:53 -08:00
|
|
|
javaVersion {
|
2023-09-25 02:38:36 -07:00
|
|
|
version = JavaVersion.VERSION_21
|
2023-01-03 06:29:13 -08:00
|
|
|
}
|
|
|
|
|
2023-11-08 00:28:07 -08:00
|
|
|
java {
|
|
|
|
toolchain {
|
|
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 06:29:13 -08:00
|
|
|
dependencies {
|
|
|
|
testImplementation(project(":core"))
|
|
|
|
testImplementation(project(":classlib"))
|
|
|
|
testImplementation(project(":jso:apis"))
|
|
|
|
testImplementation(project(":platform"))
|
|
|
|
testImplementation(project(":metaprogramming:impl"))
|
|
|
|
testImplementation(project(":tools:core"))
|
|
|
|
testImplementation(project(":tools:junit"))
|
2024-01-09 11:07:08 -08:00
|
|
|
testImplementation(project(":tools:browser-runner"))
|
2023-01-03 06:29:13 -08:00
|
|
|
testImplementation(libs.hppc)
|
|
|
|
testImplementation(libs.rhino)
|
|
|
|
testImplementation(libs.junit)
|
|
|
|
testImplementation(libs.testng)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.test {
|
2023-09-21 00:52:29 -07:00
|
|
|
systemProperty("teavm.junit.target", layout.buildDirectory.dir("teavm-tests").get().asFile.absolutePath)
|
2023-08-22 08:02:33 -07:00
|
|
|
val browser = providers.gradleProperty("teavm.tests.browser").orElse("browser-chrome").get()
|
|
|
|
|
2023-08-28 05:11:01 -07:00
|
|
|
systemProperty("teavm.junit.js", providers.gradleProperty("teavm.tests.js").orElse("true").get())
|
2023-08-22 08:02:33 -07:00
|
|
|
systemProperty("teavm.junit.js.runner", browser)
|
2023-12-20 10:49:14 -08:00
|
|
|
systemProperty("teavm.junit.minified", providers.gradleProperty("teavm.tests.minified").orElse("true").get())
|
2023-10-08 11:20:10 -07:00
|
|
|
systemProperty("teavm.junit.optimized", providers.gradleProperty("teavm.tests.optimized").orElse("true").get())
|
2023-08-22 08:02:33 -07:00
|
|
|
systemProperty("teavm.junit.js.decodeStack", providers.gradleProperty("teavm.tests.decodeStack")
|
|
|
|
.orElse("false").get())
|
|
|
|
|
2023-10-08 11:20:10 -07:00
|
|
|
systemProperty("teavm.junit.wasm", providers.gradleProperty("teavm.tests.wasm").orElse("true").get())
|
2023-08-22 08:02:33 -07:00
|
|
|
systemProperty("teavm.junit.wasm.runner", browser)
|
|
|
|
|
2023-10-08 11:20:10 -07:00
|
|
|
systemProperty("teavm.junit.wasi", providers.gradleProperty("teavm.tests.wasi").orElse("true").get())
|
2023-08-22 08:02:33 -07:00
|
|
|
systemProperty("teavm.junit.wasi.runner", providers.gradleProperty("teavm.tests.wasi.runner")
|
|
|
|
.orElse("./run-wasi.sh").get())
|
|
|
|
|
2023-10-08 11:20:10 -07:00
|
|
|
systemProperty("teavm.junit.c", providers.gradleProperty("teavm.tests.c").orElse("true").get())
|
2023-09-19 01:06:05 -07:00
|
|
|
systemProperty("teavm.junit.c.compiler", providers.gradleProperty("teavm.tests.c.compiler")
|
|
|
|
.orElse("compile-c-unix-fast.sh").get())
|
|
|
|
|
2023-10-06 01:55:08 -07:00
|
|
|
val dependencies = configurations.testRuntimeClasspath.get()
|
|
|
|
.incoming.resolutionResult.allDependencies
|
|
|
|
.asSequence()
|
|
|
|
.filterIsInstance<ResolvedDependencyResult>()
|
|
|
|
.map { it.requested }
|
|
|
|
.filterIsInstance<ProjectComponentSelector>()
|
|
|
|
.map { project.rootProject.project(it.projectPath) }
|
|
|
|
val projects = dependencies + project
|
|
|
|
val dirs = projects.map { it.layout.projectDirectory }.flatMap {
|
|
|
|
sequenceOf(
|
|
|
|
it.dir("src/main/java"),
|
|
|
|
it.dir("src/test/java")
|
|
|
|
)
|
2023-09-26 14:02:16 -07:00
|
|
|
}
|
2023-10-06 01:55:08 -07:00
|
|
|
systemProperty("teavm.junit.sourceDirs", dirs
|
|
|
|
.map { it.asFile.absolutePath }
|
|
|
|
.joinToString(File.pathSeparator))
|
2023-09-26 14:02:16 -07:00
|
|
|
|
2023-01-03 06:29:13 -08:00
|
|
|
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
|
|
|
|
}
|