Tests: Support two-stage compilation in external tests

This commit is contained in:
Ilya Matveev
2019-08-08 16:19:33 +07:00
committed by Ilya Matveev
parent d0557a3c1b
commit 843cd0001a
2 changed files with 32 additions and 7 deletions
+13 -6
View File
@@ -88,12 +88,15 @@ project.convention.plugins.executor = ExecutorServiceKt.create(project)
// Do not generate run tasks for konan built artifacts
ext.konanNoRun = true
// Enable two-stage compilation if the test_two_stage property is set.
// Enable two-stage test compilation if the test_two_stage property is set.
ext.twoStageEnabled = project.hasProperty("test_two_stage")
if (twoStageEnabled) {
tasks.withType(KonanCompileNativeBinary.class) {
enableTwoStageCompilation = true
}
tasks.withType(KonanCompileNativeBinary.class) {
enableTwoStageCompilation = twoStageEnabled
}
tasks.withType(RunExternalTestGroup.class) {
enableTwoStageCompilation = twoStageEnabled
}
allprojects {
@@ -240,10 +243,14 @@ task resultsTask() {
}
}
static boolean isExcluded(String dir) {
boolean isExcluded(String dir) {
// List of tests that fail due to unresolved compiler bugs
def excluded = [ "codegen/box/functions/bigArity" /* KT-26140 */ ]
if (project.twoStageEnabled) {
excluded += ["codegen/box/closures/captureInSuperConstructorCall", "codegen/box/enum"] // KT-33207.
}
boolean result = false
excluded.forEach {
if (dir.endsWith(it.replace("/", File.separator))) {
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecResult
@@ -297,6 +298,14 @@ class RunExternalTestGroup extends OldKonanTest {
*/
public def inDevelopersRun = false
/**
* If true, the test executable will be built in two stages:
* 1. Build a klibrary from sources.
* 2. Build a final executable from this klibrary.
*/
@Input
public def enableTwoStageCompilation = false
def groupDirectory = "."
def outputSourceSetName = "testOutputExternal"
String filter = project.findProperty("filter")
@@ -608,7 +617,16 @@ fun runTest() {
compileList.add(project.file("testUtils.kt").absolutePath)
compileList.add(project.file("helpers.kt").absolutePath)
try {
runCompiler(compileList, buildExePath(), flags)
def exePath = buildExePath()
if (enableTwoStageCompilation) {
// Two-stage compilation.
def klibPath = "${exePath}.klib"
runCompiler(compileList, klibPath, flags + ["-p", "library"])
runCompiler([], exePath, flags + ["-l", klibPath, "-Xsource-library=$klibPath"])
} else {
// Regular compilation.
runCompiler(compileList, exePath, flags)
}
} catch (Exception ex) {
project.logger.quiet("ERROR: Compilation failed for test suite: $name with exception", ex)
project.logger.quiet("The following files were unable to compile:")