Skip to content

Commit

Permalink
Always collect test results
Browse files Browse the repository at this point in the history
This should especially fix test results collection for Gradle,
where it is not possible to set test.ignoreFailures [1] from the
commandline.

[1] https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:ignoreFailures
  • Loading branch information
darxriggs committed Dec 27, 2019
1 parent 3965c16 commit b74236d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
27 changes: 15 additions & 12 deletions vars/buildPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def call(Map params = [:]) {
if (runCheckstyle) {
mavenOptions += "checkstyle:checkstyle"
}
infra.runMaven(mavenOptions, jdk, null, null, addToolEnv)
try {
infra.runMaven(mavenOptions, jdk, null, null, addToolEnv)
} finally {
if (!skipTests) {
junit('**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml')
}
}
} else {
echo "WARNING: Gradle mode for buildPlugin() is deprecated, please use buildPluginWithGradle()"
List<String> gradleOptions = [
Expand All @@ -124,21 +130,18 @@ def call(Map params = [:]) {
if (isUnix()) {
command = "./" + command
}
infra.runWithJava(command, jdk, null, addToolEnv)

try {
infra.runWithJava(command, jdk, null, addToolEnv)
} finally {
if (!skipTests) {
junit('**/build/test-results/**/*.xml')
}
}
}
}

stage("Archive (${stageIdentifier})") {
if (!skipTests) {
String testReports
if (isMaven) {
testReports = '**/target/surefire-reports/**/*.xml,**/target/failsafe-reports/**/*.xml'
} else {
testReports = '**/build/test-results/**/*.xml'
}
junit testReports
// TODO do this in a finally-block so we capture all test results even if one branch aborts early
}
if (isMaven && archiveFindbugs) {
def fp = [pattern: params?.findbugs?.pattern ?: '**/target/findbugsXml.xml']
if (params?.findbugs?.unstableNewAll) {
Expand Down
15 changes: 8 additions & 7 deletions vars/buildPluginWithGradle.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ def call(Map params = [:]) {
if (isUnix()) {
command = "./" + command
}
infra.runWithJava(command, jdk)
try {
infra.runWithJava(command, jdk)
} finally {
if (!skipTests) {
junit('**/build/test-results/**/*.xml')
}
}
}

stage("Archive (${stageIdentifier})") {
if (!skipTests) {
junit '**/build/test-results/**/*.xml'
}

//TODO(oleg-nenashev): Add static analysis results publishing like in buildPlugin() for Maven

// TODO do this in a finally-block so we capture all test results even if one branch aborts early

if (failFast && currentBuild.result == 'UNSTABLE') {
error 'There were test failures; halting early'
}
Expand Down

0 comments on commit b74236d

Please sign in to comment.