From 7693538d97dfb9658dc4cc336204de632917bf65 Mon Sep 17 00:00:00 2001 From: cliu123 Date: Wed, 30 Mar 2022 11:26:29 -0700 Subject: [PATCH] List out test failures in CI log 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 "" + } + } +}