This is an automated email from the ASF dual-hosted git repository.
davidarthur pushed a commit to branch gh-ignoreFailures
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/gh-ignoreFailures by this push:
new 44a4118dfd0 fix doLast closure
44a4118dfd0 is described below
commit 44a4118dfd066eefa0f419c241b211867c18641a
Author: David Arthur <[email protected]>
AuthorDate: Thu Sep 5 18:34:39 2024 -0400
fix doLast closure
---
.github/workflows/build.yml | 2 +-
build.gradle | 39 ++++++++++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1d24c79a5fc..a27d3df8032 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -111,7 +111,7 @@ jobs:
run: |
./gradlew --build-cache --scan --continue \
-PtestLoggingEvents=started,passed,skipped,failed \
- -PignoreFailures=true -PmaxParallelForks=2 \
+ -PmaxParallelForks=2 \
-PmaxTestRetries=1 -PmaxTestRetryFailures=10 \
-PcommitId=xxxxxxxxxxxxxxxx \
test
diff --git a/build.gradle b/build.gradle
index 8305711ef05..5b00b18596a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -470,8 +470,11 @@ subprojects {
def testsToExclude = ['**/*Suite.class']
test {
+ ext {
+ hadFailure = false // Used to track if any tests failed, see afterSuite
below
+ }
maxParallelForks = maxTestForks
- ignoreFailures = userIgnoreFailures
+ ignoreFailures = true
maxHeapSize = defaultMaxHeapSize
jvmArgs = defaultJvmArgs
@@ -499,6 +502,32 @@ subprojects {
maxFailures = userMaxTestRetryFailures
}
}
+
+ // 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.
+ //
+ // This closure will not run if a test fails and ignoreFailures is not
true.
+ doLast {
+ def dest =
rootProject.layout.buildDirectory.dir("junit-xml/${project.name}").get().asFile
+ println "Copy JUnit XML for ${project.name} to $dest"
+ ant.copy(todir: "$dest") {
+ ant.fileset(dir: "${test.reports.junitXml.entryPoint}")
+ }
+
+ // 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.")
+ }
+ }
}
task integrationTest(type: Test, dependsOn: compileJava) {
@@ -569,14 +598,6 @@ subprojects {
delete t.reports.junitXml.outputLocation
delete t.reports.html.outputLocation
}
-
- doLast {
- def dest =
rootProject.layout.buildDirectory.dir("junit-xml/${project.name}").get().asFile
- println "Copy JUnit XML for ${project.name} to $dest"
- ant.copy(todir: "$dest") {
- ant.fileset(dir: "${test.reports.junitXml.entryPoint}")
- }
- }
}
jar {