Skip to content

Commit

Permalink
List out test failures in CI log (opensearch-project#1737)
Browse files Browse the repository at this point in the history
Signed-off-by: cliu123 <[email protected]>
  • Loading branch information
cliu123 authored Apr 3, 2022
1 parent 4479638 commit f66eaf5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,28 @@ buildDeb {
arch = 'all'
archiveName "${packageName}-${version}.deb"
}

allprojects {
// add a collection to track failedTests
ext.failedTests = []

// add a testlistener to all tasks of type Test
tasks.withType(Test) {
afterTest { TestDescriptor descriptor, TestResult result ->
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
failedTests << ["${descriptor.className}::${descriptor.name}"]
}
}
}

// print out tracked failed tests when the build has finished
gradle.buildFinished {
if(!failedTests.empty){
println "Failed tests for ${project.name}:"
failedTests.each { failedTest ->
println failedTest
}
println ""
}
}
}

0 comments on commit f66eaf5

Please sign in to comment.