LUCENE-9077: Emit the location of test output on failure.

This commit is contained in:
Dawid Weiss 2020-01-15 14:01:20 +01:00
parent fee8ba6e42
commit 087b2e1c0d
2 changed files with 11 additions and 2 deletions

View File

@ -33,6 +33,10 @@ allprojects {
}
test {
ext {
testOutputsDir = file("${reports.junitXml.destination}/outputs")
}
if (verboseMode) {
maxParallelForks = 1
} else {
@ -86,7 +90,6 @@ allprojects {
}
// Set up custom test output handler.
def testOutputsDir = file("${reports.junitXml.destination}/outputs")
doFirst {
project.delete testOutputsDir
}

View File

@ -1,3 +1,5 @@
import org.apache.lucene.gradle.ErrorReportingTestListener
// Display all failed tests at the end of the build.
def failedTests = []
@ -9,6 +11,7 @@ allprojects {
failedTests << [
"name": "${desc.className}.${desc.name}",
"project": "${test.project.path}",
"output": file("${task.testOutputsDir}/${ErrorReportingTestListener.getOutputLogName(desc.parent)}"),
"reproduce": "gradlew ${project.path}:test --tests \"${desc.className}\" ${task.project.testOptionsForReproduceLine}"
]
}
@ -19,6 +22,7 @@ allprojects {
failedTests << [
"name": "${desc.name}",
"project": "${test.project.path}",
"output": file("${task.testOutputsDir}/${ErrorReportingTestListener.getOutputLogName(desc)}"),
"reproduce": "gradlew ${project.path}:test --tests \"${desc.name}\" ${task.project.testOptionsForReproduceLine}"
]
}
@ -30,7 +34,9 @@ gradle.buildFinished { result ->
if (failedTests) {
def formatted = failedTests
.sort { a, b -> b.project.compareTo(a.project) }
.collect { e -> String.format(Locale.ROOT, " - %s (%s)\n Minimum reproduce line: %s\n", e.name, e.project, e.reproduce) }
.collect { e -> String.format(Locale.ROOT,
" - %s (%s)\n Test output: %s\n Reproduce with: %s\n",
e.name, e.project, e.output, e.reproduce) }
.join("\n")
logger.error("\nERROR: The following test(s) have failed:\n${formatted}")