From 051f42667c39afedd9fb7e8d15c97b974be4a0e8 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Fri, 10 Mar 2017 13:12:38 +0700 Subject: [PATCH] build/tests: support KonanTest.expectedExitStatus --- .../main/groovy/org/jetbrains/kotlin/KonanTest.groovy | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 9d540c07dd1..6fbacde4e81 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -5,6 +5,7 @@ import org.gradle.api.DefaultTask import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.ParallelizableTask import org.gradle.api.tasks.TaskAction +import org.gradle.process.ExecResult abstract class KonanTest extends JavaExec { protected String source @@ -20,6 +21,7 @@ abstract class KonanTest extends JavaExec { String outputDirectory = null String goldValue = null String testData = null + int expectedExitStatus = 0 List arguments = null boolean enabled = true @@ -143,7 +145,7 @@ abstract class KonanTest extends JavaExec { def out = null //TODO Add test timeout - project.exec { + ExecResult execResult = project.exec { commandLine exe if (arguments != null) { args arguments @@ -156,7 +158,14 @@ abstract class KonanTest extends JavaExec { standardOutput = out } + ignoreExitValue = true } + + if (execResult.exitValue != expectedExitStatus) { + throw new TestFailedException( + "Test failed. Expected exit status: $expectedExitStatus, actual: ${execResult.exitValue}") + } + if (goldValue != null && goldValue != out.toString()) { throw new TestFailedException("Test failed. Expected output: $goldValue, actual output: ${out.toString()}") }