Tests: Support two-stage compilation in external tests
This commit is contained in:
committed by
Ilya Matveev
parent
d0557a3c1b
commit
843cd0001a
@@ -88,12 +88,15 @@ project.convention.plugins.executor = ExecutorServiceKt.create(project)
|
|||||||
// Do not generate run tasks for konan built artifacts
|
// Do not generate run tasks for konan built artifacts
|
||||||
ext.konanNoRun = true
|
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")
|
ext.twoStageEnabled = project.hasProperty("test_two_stage")
|
||||||
if (twoStageEnabled) {
|
|
||||||
tasks.withType(KonanCompileNativeBinary.class) {
|
tasks.withType(KonanCompileNativeBinary.class) {
|
||||||
enableTwoStageCompilation = true
|
enableTwoStageCompilation = twoStageEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(RunExternalTestGroup.class) {
|
||||||
|
enableTwoStageCompilation = twoStageEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
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
|
// List of tests that fail due to unresolved compiler bugs
|
||||||
def excluded = [ "codegen/box/functions/bigArity" /* KT-26140 */ ]
|
def excluded = [ "codegen/box/functions/bigArity" /* KT-26140 */ ]
|
||||||
|
|
||||||
|
if (project.twoStageEnabled) {
|
||||||
|
excluded += ["codegen/box/closures/captureInSuperConstructorCall", "codegen/box/enum"] // KT-33207.
|
||||||
|
}
|
||||||
|
|
||||||
boolean result = false
|
boolean result = false
|
||||||
excluded.forEach {
|
excluded.forEach {
|
||||||
if (dir.endsWith(it.replace("/", File.separator))) {
|
if (dir.endsWith(it.replace("/", File.separator))) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin
|
package org.jetbrains.kotlin
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.JavaExec
|
import org.gradle.api.tasks.JavaExec
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.process.ExecResult
|
import org.gradle.process.ExecResult
|
||||||
@@ -297,6 +298,14 @@ class RunExternalTestGroup extends OldKonanTest {
|
|||||||
*/
|
*/
|
||||||
public def inDevelopersRun = false
|
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 groupDirectory = "."
|
||||||
def outputSourceSetName = "testOutputExternal"
|
def outputSourceSetName = "testOutputExternal"
|
||||||
String filter = project.findProperty("filter")
|
String filter = project.findProperty("filter")
|
||||||
@@ -608,7 +617,16 @@ fun runTest() {
|
|||||||
compileList.add(project.file("testUtils.kt").absolutePath)
|
compileList.add(project.file("testUtils.kt").absolutePath)
|
||||||
compileList.add(project.file("helpers.kt").absolutePath)
|
compileList.add(project.file("helpers.kt").absolutePath)
|
||||||
try {
|
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) {
|
} catch (Exception ex) {
|
||||||
project.logger.quiet("ERROR: Compilation failed for test suite: $name with 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:")
|
project.logger.quiet("The following files were unable to compile:")
|
||||||
|
|||||||
Reference in New Issue
Block a user