tests: Generate test tasks for stdlib tests
This patch updates the test execution harness to work with the new stdlib tests. It allows one to execute stdlib tests as a part of external testing (./gradlew run_external) or separately (./gradlew run_external -Pprefix=external_stdlib).
This commit is contained in:
@@ -107,24 +107,37 @@ task run() {
|
||||
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
|
||||
// Create tasks for external tests.
|
||||
externalTestsDir.eachDirRecurse {
|
||||
Set<RunExternalTestGroup> createExternalTests(File testRoot, Closure taskConfiguration) {
|
||||
def result = new HashSet<RunExternalTestGroup>()
|
||||
testRoot.eachDirRecurse {
|
||||
// Skip build directory and directories without *.kt files.
|
||||
if (it.name == "build" || it.listFiles().count {it.name.endsWith(".kt")} == 0) {
|
||||
if (it.name == "build" || it.listFiles().count {it.name.endsWith(".kt") && it.isFile()} == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
def taskDirectory = project.relativePath(it)
|
||||
def taskName = taskDirectory.replaceAll("[-/]", '_')
|
||||
|
||||
task("$taskName", type: RunExternalTestGroup){
|
||||
def task = (RunExternalTestGroup)project.task("$taskName", type: RunExternalTestGroup){
|
||||
groupDirectory = "$taskDirectory"
|
||||
}
|
||||
taskConfiguration(task)
|
||||
result.add(task)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
task run_external () {
|
||||
// TODO Consider test output directory cleaning before execution.
|
||||
// TODO Consider using some logger instead of println
|
||||
// Create tasks for external tests.
|
||||
|
||||
for (testDir in ["codegen", "compileKotlinAgainstKotlin"]) {
|
||||
createExternalTests(new File(externalTestsDir, testDir)) {
|
||||
it.goldValue = "OK"
|
||||
}
|
||||
}
|
||||
createExternalTests(new File(externalTestsDir, "stdlib")) {}
|
||||
|
||||
// Set up dependencies.
|
||||
def testTasks = tasks.withType(RunExternalTestGroup).matching { it.enabled }
|
||||
|
||||
@@ -179,7 +179,7 @@ abstract class KonanTest extends JavaExec {
|
||||
}
|
||||
println "execution :$exe"
|
||||
|
||||
def out = null
|
||||
def out = new ByteArrayOutputStream()
|
||||
//TODO Add test timeout
|
||||
ExecResult execResult = project.execRemote {
|
||||
commandLine exe
|
||||
@@ -189,13 +189,11 @@ abstract class KonanTest extends JavaExec {
|
||||
if (testData != null) {
|
||||
standardInput = new ByteArrayInputStream(testData.bytes)
|
||||
}
|
||||
if (goldValue != null) {
|
||||
out = new ByteArrayOutputStream()
|
||||
standardOutput = out
|
||||
}
|
||||
standardOutput = out
|
||||
|
||||
ignoreExitValue = true
|
||||
}
|
||||
println(out.toString())
|
||||
|
||||
if (execResult.exitValue != expectedExitStatus) {
|
||||
throw new TestFailedException(
|
||||
@@ -399,14 +397,11 @@ class RunExternalTestGroup extends RunKonanTest {
|
||||
text.append(
|
||||
"""
|
||||
fun main(args : Array<String>) {
|
||||
@Suppress("USELESS_ELVIS")
|
||||
val result = box()?:"null"
|
||||
println(result)
|
||||
if (result != "OK") {
|
||||
throw TestFailedException(result)
|
||||
}
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val result = box()
|
||||
${ (goldValue != null) ? "print(result)" : "" }
|
||||
}
|
||||
""")
|
||||
""" )
|
||||
createFile(file, text.toString())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user