-
Notifications
You must be signed in to change notification settings - Fork 8
/
pitest-init.groovy
59 lines (55 loc) · 2.13 KB
/
pitest-init.groovy
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
import org.gradle.api.Project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.pitest:pitest:1.4.9'
classpath 'org.pitest:pitest-command-line:1.4.9'
}
}
gradle.projectsEvaluated {
ext.applyPitest = {
if (project.hasProperty('android')) {
task pitest {
// Meta-task, will dependOn pitestDebugUnitTest etc.
group 'Verification'
description 'Runs mutation tests using pitest tool.'
}
project.tasks.test.dependsOn.each { testTask ->
addPitestTask(project, testTask.name)
project.pitest.dependsOn += [project.tasks."pi${testTask.name}"]
}
}
}
if (rootProject.subprojects.isEmpty()) {
rootProject applyPitest
} else {
rootProject.subprojects applyPitest
}
}
void addPitestTask(final Project project, final String testTask) {
project.tasks.create([type:JavaExec,
name:"pi$testTask",
dependsOn:["$testTask"],]) {
ext.testSource = project.android.sourceSets.main.java.srcDirs
project.android.unitTestVariants.matching
{ it.name == testTask[4..5].toLowerCase() + testTask[5..-1] }
.sourceSets.each { testSource ->
ext.testSource += testSource.java.srcDirs
}
if (project.hasProperty('processReleaseManifest')) {
args '--reportDir', "${project.reportsDir.path}/pitest"
args '--sourceDirs', files(ext.testSource).asPath.replaceAll(':', ',')
args '--targetClasses', "${project.processReleaseManifest.packageOverride}.*"
args '--threads', '4'
args '--timestampedReports', 'false'
// args '--verbose'
classpath files(buildscript.scriptClassPath.asFiles) + project.tasks[testTask].classpath
ignoreExitValue true
jvmArgs '-XX:+CMSClassUnloadingEnabled', '-XX:MaxPermSize=2048m'
main 'org.pitest.mutationtest.commandline.MutationCoverageReport'
workingDir project.projectDir
}
}
}