Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Build: report test history URLs. Fix classMethod suffix (#2487)

David Smileyc80f344d0dfd
diff --git a/gradle/testing/failed-tests-at-end.gradle b/gradle/testing/failed-tests-at-end.gradle
index 13a1d5c720f..5bffe9c9926 100644
--- a/gradle/testing/failed-tests-at-end.gradle
+++ b/gradle/testing/failed-tests-at-end.gradle
@@ -19,43 +19,50 @@ import org.apache.lucene.gradle.ErrorReportingTestListener
// Display all failed tests at the end of the build.
-def failedTests = []
+def failedTests = new LinkedHashSet() // for dedupe due to weird afterTest classMethod issue
+
+def genFailInfo(def task, TestDescriptor desc) {
+ boolean isSuite = (desc.name == 'classMethod')
+ def name = isSuite ? desc.className : "${desc.className}.${desc.name}"
+ def historyUrl = "https://ge.apache.org/scans/tests?search.rootProjectNames=solr-root&tests.container=$desc.className"
+ if (!isSuite) { // is test method specific
+ historyUrl += "&tests.test=$desc.name"
+ historyUrl += " http://fucit.org/solr-jenkins-reports/history-trend-of-recent-failures.html#series/$name"
+ }
+ def logName = ErrorReportingTestListener.getOutputLogName(desc.parent ?: desc)
+ def output = file("${task.testOutputsDir}/${logName}")
+ def repro = "./gradlew ${task.project.path}:test --tests \"${name}\" ${task.project.testOptionsForReproduceLine}"
+ return ["name": name, "project": "${task.project.path}", "historyUrl": historyUrl, "output": output, "reproduce": repro]
+}
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}.${desc.name}\" ${task.project.testOptionsForReproduceLine}"
- ]
+ failedTests << genFailInfo(task, desc)
}
}
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}"
- ]
+ failedTests << genFailInfo(task, desc)
}
}
}
}
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}")
- }
+ if (!failedTests) return
+ def formatted = failedTests
+ .sort { a, b -> b.project <=> a.project }
+ .collect { e -> """
+ - ${e.name} (${e.project})
+ Test history: ${e.historyUrl}
+ Test output: ${e.output}
+ Reproduce with: ${e.reproduce}
+""" // In Groovy there is no incidental leading whitespace, so must fully left justify
+ }
+ .join()
+
+ logger.error("ERROR: The following test(s) have failed:${formatted}")
}