Improve output checker: default one checks with goldOutput

This commit is contained in:
Pavel Punegov
2019-02-13 14:28:11 +03:00
committed by Pavel Punegov
parent 1473565d33
commit d753da7829
@@ -40,7 +40,8 @@ abstract class KonanTest extends JavaExec {
def enableKonanAssertions = true
String outputDirectory = null
String goldValue = null
Function<String, Boolean> outputChecker = null
// Checks test's output against gold value and returns true if the output matches the expectation
Function<String, Boolean> outputChecker = { str -> (goldValue == null || goldValue == str) }
String testData = null
int expectedExitStatus = 0
List<String> arguments = null
@@ -309,10 +310,14 @@ abstract class KonanTest extends JavaExec {
}
result = result.replace(System.lineSeparator(), "\n")
def goldValueMismatch = (outputChecker != null && !outputChecker.apply(result)) ||
(goldValue != null && goldValue != result)
def goldValueMismatch = !outputChecker.apply(result)
if (goldValueMismatch) {
def message = "Expected output: $goldValue, actual output: $result"
def message
if (goldValue != null) {
message = "Expected output: $goldValue, actual output: $result"
} else {
message = "Actual output doesn't match output checker: $result"
}
if (this.expectedFail) {
println("Expected failure. $message")
} else {