Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ext {
maxTestForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : Runtime.runtime.availableProcessors()
maxScalacThreads = project.hasProperty('maxScalacThreads') ? maxScalacThreads.toInteger() :
Math.min(Runtime.runtime.availableProcessors(), 8)
userIgnoreFailures = project.hasProperty('ignoreFailures') ? ignoreFailures : false
userIgnoreFailures = project.hasProperty('ignoreFailures') ? ignoreFailures.toBoolean() : false

userMaxTestRetries = project.hasProperty('maxTestRetries') ? maxTestRetries.toInteger() : 0
userMaxTestRetryFailures = project.hasProperty('maxTestRetryFailures') ? maxTestRetryFailures.toInteger() : 0
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Comment thread
chia7712 marked this conversation as resolved.
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.
Comment thread
mumrah marked this conversation as resolved.
Outdated
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 && !userIgnoreFailures) {
throw new GradleException("Failing this task since '${project.name}:${name}' had test failures.")
}
}
}

task integrationTest(type: Test, dependsOn: compileJava) {
Expand Down Expand Up @@ -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 {
Expand Down