Skip to content

Commit

Permalink
Always print test output
Browse files Browse the repository at this point in the history
  • Loading branch information
chippmann committed May 16, 2024
1 parent 09cf6e2 commit de13044
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions harness/tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,56 +95,61 @@ tasks {
dependsOn(importResources)

val editorExecutable: String = projectDir
.resolve("../../../../bin")
.listFiles()
?.also {
println("[${it.joinToString()}]")
}
?.firstOrNull { it.name.startsWith("godot.") }
?.absolutePath
?: throw Exception("Could not find editor executable")
.resolve("../../../../bin")
.listFiles()
?.also {
println("[${it.joinToString()}]")
}
?.firstOrNull { it.name.startsWith("godot.") }
?.absolutePath
?: throw Exception("Could not find editor executable")

var didAllTestsPass = false
var isJvmClosed = false
val testOutputFile = File("$projectDir/test_output.txt")
standardOutput = testOutputFile.outputStream()
errorOutput = testOutputFile.outputStream()

doLast {
val outputLines = testOutputFile.readText().split("\n")
val testOutput = testOutputFile.readText()
val outputLines = testOutput.split("\n")

outputLines.forEach { line ->
when {
line.contains("All tests passed") -> {
didAllTestsPass = true
}

line.contains("JVM GC thread was closed") -> {
isJvmClosed = true
}
}
}

if (!didAllTestsPass) {
println(testOutputFile.readText())
throw Exception("ERROR: Some assertions failed")
}
if (!isJvmClosed) {
throw Exception("ERROR: JVM has not closed properly")
val error = when {
!didAllTestsPass -> Exception("ERROR: Some assertions failed")
!isJvmClosed -> Exception("ERROR: JVM has not closed properly")
else -> null
}

println(testOutput)

error?.let { throw it }
}

isIgnoreExitValue = true

if (HostManager.hostIsMingw) {
commandLine(
"cmd",
"/c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
"cmd",
"/c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
)
} else {
commandLine(
"bash",
"-c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
"bash",
"-c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
)
}
}
Expand Down

0 comments on commit de13044

Please sign in to comment.