mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 02:58:58 +00:00
45 lines
1.5 KiB
Groovy
45 lines
1.5 KiB
Groovy
import org.apache.lucene.gradle.ErrorReportingTestListener
|
|
|
|
// Display all failed tests at the end of the build.
|
|
|
|
def failedTests = []
|
|
|
|
allprojects {
|
|
tasks.withType(Test) { Test task ->
|
|
afterTest { desc, result ->
|
|
if (result.resultType == TestResult.ResultType.FAILURE) {
|
|
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}"
|
|
]
|
|
}
|
|
}
|
|
|
|
afterSuite { desc, result ->
|
|
if (result.exceptions) {
|
|
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}"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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 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}")
|
|
}
|
|
}
|