[K/N] Support compile-only mode for legacy test infra

This commit is contained in:
Sergey Bogolepov
2022-01-12 11:06:48 +03:00
committed by Space
parent c8cade5bf3
commit 072acf688e
4 changed files with 26 additions and 0 deletions
@@ -50,6 +50,7 @@ fun create(project: Project): ExecutorService {
val configurables = project.testTargetConfigurables
return when {
project.compileOnlyTests -> noopExecutor(project)
project.hasProperty("remote") -> sshExecutor(project, testTarget)
configurables is WasmConfigurables -> wasmExecutor(project)
configurables is ConfigurablesWithEmulator && testTarget != HostManager.host -> emulatorExecutor(project, testTarget)
@@ -59,6 +60,19 @@ fun create(project: Project): ExecutorService {
}
}
private fun noopExecutor(project: Project) = object : ExecutorService {
override val project: Project
get() = project
override fun execute(action: Action<in ExecSpec>): ExecResult? = object : ExecResult {
override fun getExitValue(): Int = 0
override fun assertNormalExitValue(): ExecResult = this
override fun rethrowFailure(): ExecResult = this
}
}
private fun wasmExecutor(project: Project) = object : ExecutorService {
val absoluteTargetToolchain = project.testTargetConfigurables.absoluteTargetToolchain
@@ -186,6 +186,9 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
// Build test executable as a first action of the task before executing the test
buildTestExecutable()
doBeforeRun?.execute(this)
if (project.compileOnlyTests) {
return
}
runTest(executorService = project.executor, testExecutable = Paths.get(executable))
}
@@ -164,6 +164,9 @@ open class KonanGTest : KonanTest() {
@TaskAction
override fun run() {
doBeforeRun?.execute(this)
if (project.compileOnlyTests) {
return
}
runProcess(
executor = { project.executor.execute(it) },
executable = executable,
@@ -302,6 +305,9 @@ open class KonanLocalTest : KonanTest() {
@TaskAction
override fun run() {
doBeforeRun?.execute(this)
if (project.compileOnlyTests) {
return
}
val times = if (multiRuns && multiArguments != null) multiArguments!!.size else 1
var output = ProcessOutput("", "", 0)
for (i in 1..times) {
@@ -86,6 +86,9 @@ val Project.testOutputExternal
val Project.cacheRedirectorEnabled
get() = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() ?: false
val Project.compileOnlyTests: Boolean
get() = hasProperty("compile-only-tests")
fun Project.redirectIfEnabled(url: String):String = if (cacheRedirectorEnabled) {
val base = URL(url)
"https://cache-redirector.jetbrains.com/${base.host}/${base.path}"