build/tests: support KonanTest.expectedExitStatus
This commit is contained in:
committed by
SvyatoslavScherbina
parent
853a40b230
commit
051f42667c
@@ -5,6 +5,7 @@ import org.gradle.api.DefaultTask
|
|||||||
import org.gradle.api.tasks.JavaExec
|
import org.gradle.api.tasks.JavaExec
|
||||||
import org.gradle.api.tasks.ParallelizableTask
|
import org.gradle.api.tasks.ParallelizableTask
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.process.ExecResult
|
||||||
|
|
||||||
abstract class KonanTest extends JavaExec {
|
abstract class KonanTest extends JavaExec {
|
||||||
protected String source
|
protected String source
|
||||||
@@ -20,6 +21,7 @@ abstract class KonanTest extends JavaExec {
|
|||||||
String outputDirectory = null
|
String outputDirectory = null
|
||||||
String goldValue = null
|
String goldValue = null
|
||||||
String testData = null
|
String testData = null
|
||||||
|
int expectedExitStatus = 0
|
||||||
List<String> arguments = null
|
List<String> arguments = null
|
||||||
|
|
||||||
boolean enabled = true
|
boolean enabled = true
|
||||||
@@ -143,7 +145,7 @@ abstract class KonanTest extends JavaExec {
|
|||||||
|
|
||||||
def out = null
|
def out = null
|
||||||
//TODO Add test timeout
|
//TODO Add test timeout
|
||||||
project.exec {
|
ExecResult execResult = project.exec {
|
||||||
commandLine exe
|
commandLine exe
|
||||||
if (arguments != null) {
|
if (arguments != null) {
|
||||||
args arguments
|
args arguments
|
||||||
@@ -156,7 +158,14 @@ abstract class KonanTest extends JavaExec {
|
|||||||
standardOutput = out
|
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()) {
|
if (goldValue != null && goldValue != out.toString()) {
|
||||||
throw new TestFailedException("Test failed. Expected output: $goldValue, actual output: ${out.toString()}")
|
throw new TestFailedException("Test failed. Expected output: $goldValue, actual output: ${out.toString()}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user