diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 0d79a804c48..09a8dd55f56 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -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 createExternalTests(File testRoot, Closure taskConfiguration) { + def result = new HashSet() + 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 } diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 1a49a20e2eb..ce0d63bee21 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -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) { - @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()) }