@@ -794,6 +794,7 @@ class Tester {
794
794
def paramsBlock = section. value[' params' ]
795
795
def stderrBlock = section. value[' stderr' ]
796
796
def stdoutBlock = section. value[' stdout' ]
797
+ def exitErrorBlock = section. value[' exit_error' ]
797
798
def inputBlock = section. value[' input' ]
798
799
def createsBlock = section. value[' creates' ]
799
800
def metricsBlock = section. value[' metrics' ]
@@ -923,6 +924,7 @@ class Tester {
923
924
StringBuilder sout
924
925
StringBuilder serr
925
926
int exitValue
927
+ boolean expectedExit // If we got a non-zero exit but it was expected
926
928
boolean timeout
927
929
if (imageName && inDocker) {
928
930
Log . info(' Docker' , ' Yes' )
@@ -1057,14 +1059,33 @@ class Tester {
1057
1059
}
1058
1060
1059
1061
} else {
1062
+
1063
+ expectedExit = false
1060
1064
if (timeout) {
1061
1065
Log . err(" Execution was terminated" +
1062
- " (taking longer than ${ testTimeoutSeconds} S)" )
1066
+ " (taking longer than ${ testTimeoutSeconds} S)" )
1067
+ } else {
1068
+ // Otherwise, was an 'exit_error' defined for this test?
1069
+ if (exitErrorBlock != null ) {
1070
+ String stderrExpr = escapeString(exitErrorBlock)
1071
+ def finder = (serr =~ / $stderrExpr/ )
1072
+ if (finder. count == 0 ) {
1073
+ Log . err(" Test failed." +
1074
+ " This was expected but did not see '$exitErrorBlock '" +
1075
+ " in the command's stderr" )
1076
+ } else {
1077
+ expectedExit = true
1078
+ }
1079
+ }
1080
+ }
1081
+
1082
+ if (! expectedExit) {
1083
+ Log . err(" Pipeline exitValue=$exitValue . <stderr> follows..." )
1063
1084
}
1064
- Log . err(" Pipeline exitValue=$exitValue . <stderr> follows..." )
1065
1085
}
1066
1086
1067
- if (exitValue == 0 && validated) {
1087
+ if (validated &&
1088
+ (exitValue == 0 || (exitValue != 0 && expectedExit) )) {
1068
1089
testsPassed + = 1
1069
1090
Log . info(' Result' , ' SUCCESS' )
1070
1091
} else {
0 commit comments