forked from FoundationDB/fdb-record-layer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.gradle
139 lines (120 loc) · 4.21 KB
/
testing.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* testing.gradle
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2018 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (hasProperty('testEnableCoverage')) {
apply plugin: 'jacoco'
tasks.withType(Test) { task ->
finalizedBy "jacoco${task.name.capitalize()}Report"
}
}
test {
useJUnit {
}
}
task jenkinsUnitTest(type: Test) {
apply plugin: "jacoco"
useJUnit {
}
if (project.hasProperty('testsToRun')) {
include testsToRun
}
outputs.upToDateWhen { false } // always re-run test tasks
jacoco.destinationFile = file("$buildDir/jacoco/${project.name}.jacocoTest.exec")
}
jacoco {
toolVersion = jacocoVersion
}
def configureTestTask = { propertyPrefix, task ->
def handled = [propertyPrefix + '.ignoreFailures',
propertyPrefix + '.debug',
propertyPrefix + '.single',
propertyPrefix + '.maxParallelForks',
propertyPrefix + '.exclude',
propertyPrefix + '.forkEvery']
System.properties.each { prop ->
def prefix = "${propertyPrefix}.sysProp."
if (!prop.key.startsWith(prefix.toString()))
return;
def setkey = prop.key.substring(prefix.length())
task.systemProperties[setkey] = prop.value
logger.debug "Set system property ${setkey} = ${prop.value} on ${propertyPrefix}"
handled.add(prop.key)
}
def tmpdir = file("$buildDir/tmp-${task.name}")
task.doFirst {
delete tmpdir
tmpdir.mkdirs()
}
task.systemProperties['java.io.tmpdir'] = tmpdir.absolutePath
// configure test logging
task.systemProperties['log4j2.configurationFile'] = rootProject.file('gradle/scripts/log4j-test.properties').toURI()
task.systemProperties['mme.app.useLog4jPropertyConfigurator'] = 'false'
// JUnit configuration parameters
task.systemProperties['junit.jupiter.execution.timeout.default'] = '5 m'
task.maxParallelForks = Integer.getInteger(propertyPrefix + '.maxParallelForks', 1)
task.forkEvery = Integer.getInteger(propertyPrefix + '.forkEvery', 0)
task.debug = Boolean.getBoolean(propertyPrefix + '.debug')
task.ignoreFailures = Boolean.getBoolean(propertyPrefix + '.ignoreFailures')
def excludes = System.getProperty(propertyPrefix + '.exclude')
if (excludes != null) {
task.exclude excludes
}
def reportsDirProperty = "${task.name}.reportsDir".toString()
handled.add(reportsDirProperty)
def reportsDir = System.getProperty(reportsDirProperty)
if (reportsDir != null) {
task.reports.junitXml.destination = reportsDir
}
System.properties.each { prop ->
if (prop.key.startsWith(propertyPrefix + '.') && !handled.contains(prop.key)) {
logger.warn "Unknown system property that looks like it was intended to configure this task: ${prop.key}=${prop.value}"
}
}
}
tasks.withType(Test) { task ->
configureTestTask('allTest', task)
configureTestTask(task.name, task)
testLogging {
events 'started', 'passed', 'failed', 'skipped'
exceptionFormat = 'full'
}
reports {
junitXml.outputPerTestCase = true
}
}
task testJar(type: Jar, dependsOn: testClasses) {
group = 'Build'
description = 'Build a jar file of test classes as an exported artifact'
classifier='test'
// baseName = "${project.archivesBaseName}-test"
from sourceSets.test.output
}
configurations {
tests {
extendsFrom testRuntime
}
}
artifacts {
tests testJar
}
task quickCheck {
group = 'Verification'
description = 'Perform fast build verification'
dependsOn testClasses
}