This is an automated email from the ASF dual-hosted git repository.

davidarthur pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 82fd7637050 MINOR Ensure quarantinedTest always copies test reports 
(#18068)
82fd7637050 is described below

commit 82fd7637050ac1f61d5910a7e35e91f86679fff9
Author: David Arthur <[email protected]>
AuthorDate: Thu Dec 5 20:36:15 2024 -0500

    MINOR Ensure quarantinedTest always copies test reports (#18068)
    
    The quarantinedTest task will fail (exit 1) if a test was too flaky. Our 
two Gradle test tasks are run with set +e so we can capture the exit code after 
the process exits. Prior to this patch, quarantinedTest was not configured with 
the Gradle ignoreFailures property which meant that it would exit upon failure. 
This prevented the test XML files from being copied to the "build-xml" 
directory for later processing.
    
    This patch adds ignoreFailures to quarantinedTest when running on CI.
    
    Reviewers: Chia-Ping Tsai <[email protected]>
---
 build.gradle | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index 6f58553879b..b1bcf2e338b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -546,6 +546,7 @@ subprojects {
   task quarantinedTest(type: Test, dependsOn: compileJava) {
     ext {
       isGithubActions = System.getenv('GITHUB_ACTIONS') != null
+      hadFailure = false  // Used to track if any tests failed, see afterSuite 
below
     }
 
     // Disable caching and up-to-date for this task. We always want 
quarantined tests
@@ -555,7 +556,7 @@ subprojects {
     outputs.cacheIf { false }
 
     maxParallelForks = maxTestForks
-    ignoreFailures = userIgnoreFailures
+    ignoreFailures = userIgnoreFailures || ext.isGithubActions
 
     maxHeapSize = defaultMaxHeapSize
     jvmArgs = defaultJvmArgs
@@ -584,6 +585,13 @@ subprojects {
       }
     }
 
+    // As we process results, check if there were any test failures.
+    afterSuite { desc, result ->
+      if (result.resultType == TestResult.ResultType.FAILURE) {
+        ext.hadFailure = true
+      }
+    }
+
     // This closure will copy JUnit XML files out of the sub-project's build 
directory and into
     // a top-level build/junit-xml directory. This is necessary to avoid 
reporting on tests which
     // were not run, but instead were restored via FROM-CACHE. See KAFKA-17479 
for more details.
@@ -597,6 +605,11 @@ subprojects {
             ant.include(name: "**/*.xml")
           }
         }
+        // If there were any test failures, we want to fail the task to 
prevent the failures
+        // from being cached.
+        if (ext.hadFailure) {
+          throw new GradleException("Failing this task since 
'${project.name}:${name}' had test failures.")
+        }
       }
     }
   }

Reply via email to