mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Enable filtering across all test tasks (#311)
The segregated test targets in core break the --tests filter. Fix this by defining a "testFilter" property and creating the FilteringTest task type that applies it to the property set by "--tests".
This commit is contained in:
parent
e690fa895f
commit
214a3af612
2 changed files with 38 additions and 11 deletions
|
@ -558,10 +558,38 @@ artifacts {
|
||||||
testRuntime testJar
|
testRuntime testJar
|
||||||
}
|
}
|
||||||
|
|
||||||
task fragileTest(type: Test) {
|
/**
|
||||||
|
* We have to break out the test suites because some of the tests conflict
|
||||||
|
* with one another, but unfortunately this breaks the "--tests" flag. The
|
||||||
|
* --tests flag only applies to the task named on the command line (usually
|
||||||
|
* just "test"), not for all tasks of type "Test".
|
||||||
|
*
|
||||||
|
* As a better solution, FilteringTest sets testNameIncludePatterns (the
|
||||||
|
* internal property that --tests sets) from the value of the "testFilter"
|
||||||
|
* property, allowing us to filter across all the tests in core without
|
||||||
|
* explicitly specifying a test task or causing errors because there are no
|
||||||
|
* matching tests in the main task.
|
||||||
|
*
|
||||||
|
* To use it, define "testFilter" to be a comma-separated collection of class
|
||||||
|
* names (wildcards are allowed):
|
||||||
|
*
|
||||||
|
* ./gradlew test -P testFilter=*.FooBar,google.registry.tools.ShellCommandTest
|
||||||
|
*/
|
||||||
|
class FilteringTest extends Test {
|
||||||
|
|
||||||
|
void setTests(List<String> tests) {
|
||||||
// Common exclude pattern. See README in parent directory for explanation.
|
// Common exclude pattern. See README in parent directory for explanation.
|
||||||
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
||||||
include fragileTestPatterns
|
include tests
|
||||||
|
if (project.testFilter) {
|
||||||
|
testNameIncludePatterns = project.testFilter.split(',')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task fragileTest(type: FilteringTest) {
|
||||||
|
// Common exclude pattern. See README in parent directory for explanation.
|
||||||
|
tests = fragileTestPatterns
|
||||||
|
|
||||||
if (rootProject.findProperty("skipDockerIncompatibleTests") == "true") {
|
if (rootProject.findProperty("skipDockerIncompatibleTests") == "true") {
|
||||||
exclude dockerIncompatibleTestPatterns
|
exclude dockerIncompatibleTestPatterns
|
||||||
|
@ -571,10 +599,8 @@ task fragileTest(type: Test) {
|
||||||
forkEvery 1
|
forkEvery 1
|
||||||
}
|
}
|
||||||
|
|
||||||
task outcastTest(type: Test) {
|
task outcastTest(type: FilteringTest) {
|
||||||
// Common exclude pattern. See README in parent directory for explanation.
|
tests = outcastTestPatterns
|
||||||
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
|
||||||
include outcastTestPatterns
|
|
||||||
|
|
||||||
// Sets the maximum number of test executors that may exist at the same time.
|
// Sets the maximum number of test executors that may exist at the same time.
|
||||||
maxParallelForks 5
|
maxParallelForks 5
|
||||||
|
@ -630,10 +656,8 @@ task registryTool(type: JavaExec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task generateGoldenImages(type: Test) {
|
task generateGoldenImages(type: FilteringTest) {
|
||||||
// Common exclude pattern. See README in parent directory for explanation.
|
tests = ["**/webdriver/*"]
|
||||||
exclude "**/*TestCase.*", "**/*TestSuite.*"
|
|
||||||
include "**/webdriver/*"
|
|
||||||
|
|
||||||
// Sets the maximum number of test executors that may exist at the same time.
|
// Sets the maximum number of test executors that may exist at the same time.
|
||||||
maxParallelForks 5
|
maxParallelForks 5
|
||||||
|
|
|
@ -8,6 +8,9 @@ verboseTestOutput=false
|
||||||
flowDocsFile=
|
flowDocsFile=
|
||||||
enableDependencyLocking=true
|
enableDependencyLocking=true
|
||||||
|
|
||||||
|
# Comma separated list of test patterns, if specified run only these.
|
||||||
|
testFilter=
|
||||||
|
|
||||||
# GAE Environment for deployment and staging.
|
# GAE Environment for deployment and staging.
|
||||||
environment=
|
environment=
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue