From 0e67fbb7ad196896d2574ad0cf6c54fc80e4aed7 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Mon, 24 Jul 2017 15:41:06 +0700 Subject: [PATCH] tests: Add assert tests --- backend.native/tests/build.gradle | 15 +++++++++++++-- .../basic/{failed_assert.kt => assert_failed.kt} | 0 .../tests/runtime/basic/assert_passed.kt | 3 +++ .../groovy/org/jetbrains/kotlin/KonanTest.groovy | 9 +++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) rename backend.native/tests/runtime/basic/{failed_assert.kt => assert_failed.kt} (100%) create mode 100644 backend.native/tests/runtime/basic/assert_passed.kt diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index ac401ae0e01..7f70260f657 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -1516,9 +1516,20 @@ task main_exception(type: RunKonanTest) { source = "runtime/basic/main_exception.kt" } -task failed_assert(type: RunKonanTest) { +task runtime_basic_assert_failed(type: RunKonanTest) { expectedExitStatus = 1 - source = "runtime/basic/failed_assert.kt" + source = "runtime/basic/assert_failed.kt" +} + +task runtime_basic_assert_passed(type: RunKonanTest) { + expectedExitStatus = 0 + source = "runtime/basic/assert_passed.kt" +} + +task runtime_basic_assert_disabled(type: RunKonanTest) { + expectedExitStatus = 0 + enableKonanAssertions = false + source = "runtime/basic/assert_failed.kt" } task initializers0(type: RunKonanTest) { diff --git a/backend.native/tests/runtime/basic/failed_assert.kt b/backend.native/tests/runtime/basic/assert_failed.kt similarity index 100% rename from backend.native/tests/runtime/basic/failed_assert.kt rename to backend.native/tests/runtime/basic/assert_failed.kt diff --git a/backend.native/tests/runtime/basic/assert_passed.kt b/backend.native/tests/runtime/basic/assert_passed.kt new file mode 100644 index 00000000000..74bced5d157 --- /dev/null +++ b/backend.native/tests/runtime/basic/assert_passed.kt @@ -0,0 +1,3 @@ +fun main(args: Array) { + assert(true) +} \ No newline at end of file diff --git a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 4483cd0055b..890f4887b16 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -38,6 +38,7 @@ abstract class KonanTest extends JavaExec { def konanc = new File("${dist.canonicalPath}/bin/$konancDriver").absolutePath def mainC = 'main.c' def outputSourceSetName = "testOutputLocal" + def enableKonanAssertions = true String outputDirectory = null String goldValue = null String testData = null @@ -97,13 +98,15 @@ abstract class KonanTest extends JavaExec { classpath = project.configurations.cli_bc enableAssertions = true args = ["-output", output, - "-ea", *filesToCompile, *moreArgs, *project.globalTestArgs] if (project.testTarget) { args "-target", project.testTarget } + if (enableKonanAssertions) { + args "-ea" + } standardOutput = log errorOutput = log super.exec() @@ -282,13 +285,15 @@ class RunDriverKonanTest extends KonanTest { project.exec { commandLine konanc args = ["-output", output, - "-ea", *filesToCompile, *moreArgs, *project.globalTestArgs] if (project.testTarget) { args "-target", project.testTarget } + if (enableKonanAssertions) { + args "-ea" + } standardOutput = log errorOutput = log }