2019-12-02 09:34:57 -05:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
2020-01-22 09:54:08 -05:00
|
|
|
import org.apache.tools.ant.types.Commandline
|
2019-12-02 09:34:57 -05:00
|
|
|
import org.gradle.api.tasks.testing.logging.*
|
2020-01-07 11:03:01 -05:00
|
|
|
import org.apache.lucene.gradle.ErrorReportingTestListener
|
2019-12-02 09:34:57 -05:00
|
|
|
|
2019-12-07 08:53:13 -05:00
|
|
|
def verboseModeHookInstalled = false
|
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
allprojects {
|
|
|
|
plugins.withType(JavaPlugin) {
|
2019-12-08 13:06:01 -05:00
|
|
|
def verboseMode = Boolean.parseBoolean(propertyOrDefault("tests.verbose", "false"))
|
2019-12-07 08:53:13 -05:00
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
project.ext {
|
2020-01-22 09:54:08 -05:00
|
|
|
testsCwd = file("${buildDir}/tmp/tests-cwd")
|
|
|
|
testsTmpDir = file(propertyOrDefault("tests.workDir", "${buildDir}/tmp/tests-tmp"))
|
2019-12-06 13:25:57 -05:00
|
|
|
commonDir = project(":lucene").projectDir
|
|
|
|
commonSolrDir = project(":solr").projectDir
|
2019-12-02 09:34:57 -05:00
|
|
|
}
|
|
|
|
|
2019-12-07 08:53:13 -05:00
|
|
|
// 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.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
test {
|
2020-01-15 08:01:20 -05:00
|
|
|
ext {
|
|
|
|
testOutputsDir = file("${reports.junitXml.destination}/outputs")
|
|
|
|
}
|
|
|
|
|
2019-12-07 08:53:13 -05:00
|
|
|
if (verboseMode) {
|
|
|
|
maxParallelForks = 1
|
|
|
|
} else {
|
|
|
|
maxParallelForks = propertyOrDefault("tests.jvms", (int) Math.max(1, Math.min(Runtime.runtime.availableProcessors() / 2.0, 4.0)))
|
|
|
|
}
|
2019-12-02 09:34:57 -05:00
|
|
|
|
2020-01-22 09:54:08 -05:00
|
|
|
workingDir testsCwd
|
2019-12-02 09:34:57 -05:00
|
|
|
useJUnit()
|
|
|
|
|
2020-01-22 09:54:08 -05:00
|
|
|
minHeapSize = propertyOrDefault("tests.minheapsize", "256m")
|
|
|
|
maxHeapSize = propertyOrDefault("tests.heapsize", "512m")
|
|
|
|
|
|
|
|
jvmArgs Commandline.translateCommandline(propertyOrDefault("tests.jvmargs", "-XX:TieredStopAtLevel=1"))
|
2019-12-02 09:34:57 -05:00
|
|
|
|
2019-12-06 05:55:53 -05:00
|
|
|
systemProperty 'java.util.logging.config.file', file("${commonDir}/tools/junit4/logging.properties")
|
2019-12-02 09:34:57 -05:00
|
|
|
systemProperty 'java.awt.headless', 'true'
|
|
|
|
systemProperty 'jdk.map.althashing.threshold', '0'
|
|
|
|
|
|
|
|
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
systemProperty 'java.security.egd', 'file:/dev/./urandom'
|
|
|
|
}
|
|
|
|
|
2019-12-06 05:55:53 -05:00
|
|
|
// jetty-related.
|
|
|
|
systemProperty 'jetty.testMode', '1'
|
|
|
|
systemProperty 'jetty.insecurerandom', '1'
|
|
|
|
|
|
|
|
// Turn jenkins blood red for hashmap bugs, even on jdk7
|
|
|
|
systemProperty 'jdk.map.althashing.threshold', '0'
|
|
|
|
|
2019-12-09 10:43:44 -05:00
|
|
|
// Pass these to RandomizedRunner so that it doesn't attempt to set them.
|
|
|
|
systemProperty 'junit4.childvm.count', '1'
|
|
|
|
systemProperty 'junit4.childvm.id', '0'
|
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
// Set up cwd and temp locations.
|
|
|
|
systemProperty("java.io.tmpdir", testsTmpDir)
|
2019-12-06 05:55:53 -05:00
|
|
|
systemProperty("tempDir", testsTmpDir)
|
2019-12-02 09:34:57 -05:00
|
|
|
doFirst {
|
2020-01-22 09:54:08 -05:00
|
|
|
testsCwd.mkdirs()
|
2019-12-02 09:34:57 -05:00
|
|
|
testsTmpDir.mkdirs()
|
|
|
|
}
|
|
|
|
|
2020-01-07 11:03:01 -05:00
|
|
|
// Disable HTML report generation. The reports are big and slow to generate.
|
|
|
|
reports.html.enabled = false
|
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
// Set up logging.
|
2020-01-08 05:38:34 -05:00
|
|
|
testLogging {
|
|
|
|
events TestLogEvent.FAILED
|
|
|
|
exceptionFormat TestExceptionFormat.FULL
|
|
|
|
showExceptions true
|
|
|
|
showCauses true
|
|
|
|
showStackTraces true
|
|
|
|
showStandardStreams false
|
|
|
|
}
|
2020-01-08 04:55:07 -05:00
|
|
|
|
2020-01-08 05:38:34 -05:00
|
|
|
// Set up custom test output handler.
|
|
|
|
doFirst {
|
|
|
|
project.delete testOutputsDir
|
2019-12-02 09:34:57 -05:00
|
|
|
}
|
|
|
|
|
2020-01-08 05:38:34 -05:00
|
|
|
def spillDir = getTemporaryDir().toPath()
|
|
|
|
def listener = new ErrorReportingTestListener(test.testLogging, spillDir, testOutputsDir.toPath(), verboseMode)
|
|
|
|
addTestOutputListener(listener)
|
|
|
|
addTestListener(listener)
|
|
|
|
|
2019-12-02 09:34:57 -05:00
|
|
|
doFirst {
|
|
|
|
// Print some diagnostics about locations used.
|
2020-01-22 09:54:08 -05:00
|
|
|
logger.info("Test folders for {}: cwd={}, tmp={}", project.path, testsCwd, testsTmpDir)
|
2019-12-02 09:34:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|