backend/tests: Generate external test tasks in config stage
We generate tasks for external tests group during Gradle's configuration phase instead of using separate task (regenerate_external_tests)
This commit is contained in:
@@ -10,16 +10,17 @@ dependencies {
|
||||
}
|
||||
|
||||
def testOutputRoot = rootProject.file("test.output").absolutePath
|
||||
def externalTestsDir = project.file("external")
|
||||
|
||||
allprojects {
|
||||
// Root directories for test output (logs, compiled files, statistics etc). Only single path must be in each set.
|
||||
sourceSets {
|
||||
// :backend.native:tests
|
||||
// backend.native/tests
|
||||
testOutputLocal {
|
||||
output.dir(rootProject.file("$testOutputRoot/local"))
|
||||
}
|
||||
|
||||
// :backend.native:tests:external
|
||||
// backend.native/tests/external
|
||||
testOutputExternal {
|
||||
output.dir(rootProject.file("$testOutputRoot/external"))
|
||||
}
|
||||
@@ -32,63 +33,28 @@ task clean {
|
||||
}
|
||||
}
|
||||
|
||||
task regenerate_external_tests() {
|
||||
doLast {
|
||||
def externalTestsProject = childProjects["external"]
|
||||
def gradleGenerated = externalTestsProject.file("build.gradle")
|
||||
def externalTestsDir = externalTestsProject.file("codegen/blackbox")
|
||||
gradleGenerated.write("import org.jetbrains.kotlin.*\n")
|
||||
gradleGenerated.append(
|
||||
"""
|
||||
/*******************************************************************************
|
||||
* WARNING: This file auto generated with command
|
||||
* # ./gradlew :backend.native:tests:regenerate_external_tests
|
||||
*******************************************************************************/
|
||||
configurations {
|
||||
cli_bc
|
||||
}
|
||||
|
||||
dependencies {
|
||||
cli_bc project(path: ':backend.native', configuration: 'cli_bc')
|
||||
}
|
||||
"""
|
||||
)
|
||||
externalTestsDir.eachDirRecurse {
|
||||
// Skip build directory and directories without *.kt files.
|
||||
if (it.name == "build" || it.listFiles().count {it.name.endsWith(".kt")} == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
def taskDirectory = externalTestsProject.relativePath(it)
|
||||
def taskName = taskDirectory.replaceAll("[-/]", '_')
|
||||
|
||||
gradleGenerated.append(
|
||||
"task $taskName (type: RunExternalTestGroup) {\n" +
|
||||
" groupDirectory = \"$taskDirectory\"\n" +
|
||||
"}\n\n")
|
||||
}
|
||||
gradleGenerated.append(
|
||||
"""
|
||||
task daily {
|
||||
dependsOn(codegen_blackbox_annotations)
|
||||
}
|
||||
|
||||
task run() {
|
||||
dependsOn(tasks.withType(RunExternalTestGroup).matching { it.enabled })
|
||||
}
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task run() {
|
||||
dependsOn(tasks.withType(KonanTest).matching { it.enabled })
|
||||
dependsOn(tasks.withType(KonanTest).matching { !(it instanceof RunExternalTestGroup) && it.enabled })
|
||||
}
|
||||
|
||||
task run_external () {
|
||||
// TODO Consider test output directory cleaning before execution.
|
||||
// TODO Consider using some logger instead of println
|
||||
def testTasks = childProjects["external"].tasks.withType(RunExternalTestGroup).matching { it.enabled }
|
||||
// Create tasks for external tests
|
||||
externalTestsDir.eachDirRecurse {
|
||||
// Skip build directory and directories without *.kt files.
|
||||
if (it.name == "build" || it.listFiles().count {it.name.endsWith(".kt")} == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
def taskDirectory = project.relativePath(it)
|
||||
def taskName = taskDirectory.replaceAll("[-/]", '_')
|
||||
|
||||
task("$taskName", type: RunExternalTestGroup){
|
||||
groupDirectory = "$taskDirectory"
|
||||
}
|
||||
}
|
||||
def testTasks = tasks.withType(RunExternalTestGroup).matching { it.enabled }
|
||||
dependsOn(testTasks)
|
||||
|
||||
doLast {
|
||||
@@ -111,6 +77,10 @@ task run_external () {
|
||||
}
|
||||
}
|
||||
|
||||
task daily() {
|
||||
dependsOn(run_external)
|
||||
}
|
||||
|
||||
task sum (type:RunKonanTest) {
|
||||
source = "codegen/function/sum.kt"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user