From 9fd555471a358c7a848d86a3fb8dba3645a48cd1 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Fri, 31 Mar 2017 03:38:16 +0300 Subject: [PATCH] A couple of konanc driver tests. --- backend.native/tests/build.gradle | 13 ++++++++ .../org/jetbrains/kotlin/KonanTest.groovy | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 2a9850d4d5b..0d79a804c48 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -1554,11 +1554,24 @@ task deserialized_inline0(type: RunKonanTest) { source = "serialization/deserialized_inline0.kt" flags = ["--enable", "deserializer"] } + task deserialized_listof0(type: RunKonanTest) { source = "serialization/deserialized_listof0.kt" flags = ["--enable", "deserializer"] } +// Just check that the driver is able to produce runnable binaries. +task driver0(type: RunDriverKonanTest) { + goldValue = "Hello, world!\n" + source = "runtime/basic/hello0.kt" +} + +task driver_opt(type: RunDriverKonanTest) { + goldValue = "Hello, world!\n" + source = "runtime/basic/hello0.kt" + flags = ["-opt"] +} + // Enable when deserialization for default arguments is fixed. task inline_defaultArgs_linkTest(type: LinkKonanTest) { disabled = true diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index daf2c09e618..1a49a20e2eb 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -33,6 +33,7 @@ abstract class KonanTest extends JavaExec { def launcherBc = new File("${dist.canonicalPath}/lib/launcher.bc").absolutePath def startKtBc = new File("${dist.canonicalPath}/lib/start.kt.bc").absolutePath def stdlibKtBc = new File("${dist.canonicalPath}/lib/stdlib.kt.bc").absolutePath + def konanc = new File("${dist.canonicalPath}/bin/konanc").absolutePath def mainC = 'main.c' def outputSourceSetName = "testOutputLocal" String outputDirectory = null @@ -219,6 +220,37 @@ class RunKonanTest extends KonanTest { } } +// This is another way to run the compiler. +// Don't use this task for regular testing as +// project.exec + a shell script isolate the jvm +// from IDEA. Use the RunKonanTest instead. +@ParallelizableTask +class RunDriverKonanTest extends KonanTest { + void compileTest(List filesToCompile, String exe) { + runCompiler(filesToCompile, exe, flags?:[]) + } + + protected void runCompiler(List filesToCompile, String output, List moreArgs) { + def log = new ByteArrayOutputStream() + project.exec { + commandLine konanc + args = ["-output", output, + "-ea", + *filesToCompile, + *moreArgs, + *project.globalTestArgs] + if (project.testTarget) { + args "-target", project.testTarget + } + standardOutput = log + errorOutput = log + } + def logString = log.toString() + project.file("${output}.compilation.log").write(logString) + println(logString) + } +} + @ParallelizableTask class RunInteropKonanTest extends KonanTest {