From f66eaf571b916fdcbb7c1e121c492e256303b2f1 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Sat, 2 Apr 2022 22:25:00 -0700 Subject: [PATCH] List out test failures in CI log (#1737) Signed-off-by: cliu123 --- build.gradle | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/build.gradle b/build.gradle index afe43b9b49..10818763c7 100644 --- a/build.gradle +++ b/build.gradle @@ -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 "" + } + } +}