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 })
|
dependsOn(tasks.withType(KonanTest).matching { !(it instanceof RunExternalTestGroup) && it.enabled })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<RunExternalTestGroup> createExternalTests(File testRoot, Closure taskConfiguration) {
|
||||||
task run_external () {
|
def result = new HashSet<RunExternalTestGroup>()
|
||||||
// TODO Consider test output directory cleaning before execution.
|
testRoot.eachDirRecurse {
|
||||||
// TODO Consider using some logger instead of println
|
|
||||||
// Create tasks for external tests.
|
|
||||||
externalTestsDir.eachDirRecurse {
|
|
||||||
// Skip build directory and directories without *.kt files.
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
def taskDirectory = project.relativePath(it)
|
def taskDirectory = project.relativePath(it)
|
||||||
def taskName = taskDirectory.replaceAll("[-/]", '_')
|
def taskName = taskDirectory.replaceAll("[-/]", '_')
|
||||||
|
|
||||||
task("$taskName", type: RunExternalTestGroup){
|
def task = (RunExternalTestGroup)project.task("$taskName", type: RunExternalTestGroup){
|
||||||
groupDirectory = "$taskDirectory"
|
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.
|
// Set up dependencies.
|
||||||
def testTasks = tasks.withType(RunExternalTestGroup).matching { it.enabled }
|
def testTasks = tasks.withType(RunExternalTestGroup).matching { it.enabled }
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ abstract class KonanTest extends JavaExec {
|
|||||||
}
|
}
|
||||||
println "execution :$exe"
|
println "execution :$exe"
|
||||||
|
|
||||||
def out = null
|
def out = new ByteArrayOutputStream()
|
||||||
//TODO Add test timeout
|
//TODO Add test timeout
|
||||||
ExecResult execResult = project.execRemote {
|
ExecResult execResult = project.execRemote {
|
||||||
commandLine exe
|
commandLine exe
|
||||||
@@ -189,13 +189,11 @@ abstract class KonanTest extends JavaExec {
|
|||||||
if (testData != null) {
|
if (testData != null) {
|
||||||
standardInput = new ByteArrayInputStream(testData.bytes)
|
standardInput = new ByteArrayInputStream(testData.bytes)
|
||||||
}
|
}
|
||||||
if (goldValue != null) {
|
standardOutput = out
|
||||||
out = new ByteArrayOutputStream()
|
|
||||||
standardOutput = out
|
|
||||||
}
|
|
||||||
|
|
||||||
ignoreExitValue = true
|
ignoreExitValue = true
|
||||||
}
|
}
|
||||||
|
println(out.toString())
|
||||||
|
|
||||||
if (execResult.exitValue != expectedExitStatus) {
|
if (execResult.exitValue != expectedExitStatus) {
|
||||||
throw new TestFailedException(
|
throw new TestFailedException(
|
||||||
@@ -399,14 +397,11 @@ class RunExternalTestGroup extends RunKonanTest {
|
|||||||
text.append(
|
text.append(
|
||||||
"""
|
"""
|
||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
@Suppress("USELESS_ELVIS")
|
@Suppress("UNUSED_VARIABLE")
|
||||||
val result = box()?:"null"
|
val result = box()
|
||||||
println(result)
|
${ (goldValue != null) ? "print(result)" : "" }
|
||||||
if (result != "OK") {
|
|
||||||
throw TestFailedException(result)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
""")
|
""" )
|
||||||
createFile(file, text.toString())
|
createFile(file, text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user