mirror of
https://github.com/apache/lucene.git
synced 2025-02-21 01:18:45 +00:00
Add some support for -Ptests.verbose mode when streams are dumped to the console. This is constrained by gradle's runner but is better than nothing.
This commit is contained in:
parent
c3bb81f032
commit
1021f04d1a
@ -1,8 +1,12 @@
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.tasks.testing.logging.*
|
||||
|
||||
def verboseModeHookInstalled = false
|
||||
|
||||
allprojects {
|
||||
plugins.withType(JavaPlugin) {
|
||||
def verboseMode = propertyOrDefault("tests.verbose", "false")
|
||||
|
||||
project.ext {
|
||||
testsWorkDir = file("${buildDir}/tmp/tests-cwd")
|
||||
testsTmpDir = file("${buildDir}/tmp/tests-tmp")
|
||||
@ -10,13 +14,33 @@ allprojects {
|
||||
commonSolrDir = project(":solr").projectDir
|
||||
}
|
||||
|
||||
// If we're running in verbose mode and:
|
||||
// 1) worker count > 1
|
||||
// 2) number of 'test' tasks in the build is > 1
|
||||
// then the output would very likely be mangled on the
|
||||
// console. Fail and let the user know what to do.
|
||||
if (verboseMode && !verboseModeHookInstalled) {
|
||||
verboseModeHookInstalled = true
|
||||
if (gradle.startParameter.maxWorkerCount > 1) {
|
||||
gradle.taskGraph.whenReady { graph ->
|
||||
def testTasks = graph.allTasks.findAll { task -> task instanceof Test }
|
||||
if (testTasks.size() > 1) {
|
||||
throw new GradleException("Run your tests in verbose mode only with --max-workers=1 option passed to gradle.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
if (verboseMode) {
|
||||
maxParallelForks = 1
|
||||
} else {
|
||||
maxParallelForks = propertyOrDefault("tests.jvms", (int) Math.max(1, Math.min(Runtime.runtime.availableProcessors() / 2.0, 4.0)))
|
||||
}
|
||||
|
||||
workingDir testsWorkDir
|
||||
|
||||
useJUnit()
|
||||
|
||||
maxParallelForks = propertyOrDefault("tests.jvms", (int) Math.max(1, Math.min(Runtime.runtime.availableProcessors() / 2.0, 4.0)))
|
||||
|
||||
minHeapSize = "256m"
|
||||
maxHeapSize = "512m"
|
||||
|
||||
@ -44,12 +68,26 @@ allprojects {
|
||||
}
|
||||
|
||||
// Set up logging.
|
||||
testLogging {
|
||||
events TestLogEvent.FAILED
|
||||
exceptionFormat TestExceptionFormat.FULL
|
||||
showExceptions true
|
||||
showCauses true
|
||||
showStackTraces true
|
||||
if (verboseMode) {
|
||||
testLogging {
|
||||
events TestLogEvent.FAILED
|
||||
exceptionFormat TestExceptionFormat.FULL
|
||||
showExceptions true
|
||||
showCauses true
|
||||
showStackTraces true
|
||||
showStandardStreams = false
|
||||
}
|
||||
onOutput { td, event ->
|
||||
print event.message
|
||||
}
|
||||
} else {
|
||||
testLogging {
|
||||
events TestLogEvent.FAILED
|
||||
exceptionFormat TestExceptionFormat.FULL
|
||||
showExceptions true
|
||||
showCauses true
|
||||
showStackTraces true
|
||||
}
|
||||
}
|
||||
|
||||
doFirst {
|
||||
|
@ -22,8 +22,12 @@ gradle.taskGraph.whenReady { graph ->
|
||||
// ... and there are some test tasks in the execution graph.
|
||||
if (!testTasks.isEmpty()) {
|
||||
def executedTests = 0
|
||||
def executedTasks = 0
|
||||
|
||||
testTasks.each { task ->
|
||||
task.doFirst {
|
||||
executedTasks++
|
||||
}
|
||||
task.afterSuite { desc, result ->
|
||||
executedTests += result.testCount
|
||||
}
|
||||
@ -31,7 +35,7 @@ gradle.taskGraph.whenReady { graph ->
|
||||
|
||||
// After the build is finished, check the test count.
|
||||
gradle.buildFinished {
|
||||
if (executedTests == 0) {
|
||||
if (executedTests == 0 && executedTasks > 0) {
|
||||
throw new GradleException("No tests found for the given filters?")
|
||||
}
|
||||
}
|
||||
|
@ -94,13 +94,11 @@ cleanTest task:
|
||||
gradlew -p lucene/core cleanTest test -Ptests.seed=deadbeef
|
||||
|
||||
|
||||
Verbose mode and debugging
|
||||
--------------------------
|
||||
|
||||
The "tests.verbose" mode switch enables standard streams from tests
|
||||
to be dumped directly to the console. Run your verbose tests explicitly
|
||||
specifying the project and test task or a fully qualified task path. Example:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gradlew -p lucene/core test -Ptests.verbose=true --tests "TestDemo"
|
||||
|
Loading…
x
Reference in New Issue
Block a user