borinquenkid commented on code in PR #16819:
URL: https://github.com/apache/grails-core/pull/16819#discussion_r4449327106
##########
build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsCodeAnalysisPlugin.groovy:
##########
@@ -219,6 +271,69 @@ class GrailsCodeAnalysisPlugin implements Plugin<Project> {
}
}
+ private static void configurePitest(Project project,
GrailsCodeAnalysisExtension extension) {
+ Runnable applyAndConfigure = {
+ if (project.pluginManager.hasPlugin('info.solidsoft.pitest')) {
+ return
+ }
+ project.pluginManager.apply(PitestPlugin)
+
+ def targetClassesProp =
project.providers.gradleProperty(PITEST_TARGET_CLASSES_PROPERTY)
+ def targetTestsProp =
project.providers.gradleProperty(PITEST_TARGET_TESTS_PROPERTY)
+ def threadsProp =
project.providers.gradleProperty(PITEST_THREADS_PROPERTY)
+ def mutatorsProp =
project.providers.gradleProperty(PITEST_MUTATORS_PROPERTY)
+
+ project.extensions.configure(PitestPluginExtension) {
PitestPluginExtension pitest ->
+ String configuredPitestVersion =
project.findProperty('pitestVersion') as String
+ if (configuredPitestVersion) {
+ pitest.pitestVersion.set(configuredPitestVersion)
+ }
+ String configuredJunit5Version =
project.findProperty('pitestJunit5PluginVersion') as String
+ if (configuredJunit5Version) {
+ pitest.junit5PluginVersion.set(configuredJunit5Version)
+ }
+ pitest.useClasspathFile.set(true)
+ pitest.outputFormats.set(['XML', 'HTML'] as Set<String>)
+ pitest.timestampedReports.set(false)
+ pitest.failWhenNoMutations.set(false)
+ pitest.threads.set(threadsProp.map {
Integer.parseInt(it.trim()) }.orElse(4))
+ pitest.excludedMethods.set(GROOVY_EXCLUDED_METHODS)
+ pitest.excludedClasses.set(GROOVY_EXCLUDED_CLASSES)
+ pitest.avoidCallsTo.set(GROOVY_AVOID_CALLS_TO)
+
pitest.reportDir.set(extension.reportsDirectory.dir("pitest/${project.name}"))
+
+ if (targetClassesProp.present) {
+ pitest.targetClasses.set(targetClassesProp.map {
it.split(',')*.trim().findAll() as Set<String> })
+ } else if (project.group) {
+ pitest.targetClasses.set(["${project.group}.*" as String,
'org.grails.*', 'grails.*'] as Set<String>)
+ }
+ if (targetTestsProp.present) {
+ pitest.targetTests.set(targetTestsProp.map {
it.split(',')*.trim().findAll() as Set<String> })
+ }
+ if (mutatorsProp.present) {
+ pitest.mutators.set(mutatorsProp.map {
it.split(',')*.trim().findAll() as Set<String> })
+ }
+ }
+ }
+
+ if (project.plugins.hasPlugin('java')) {
+ applyAndConfigure.run()
+ } else {
+ project.plugins.withId('java') {
+ applyAndConfigure.run()
+ }
+ }
+ }
+
+ private static boolean isPitestTaskRequested(Project project) {
+ project.gradle.startParameter.taskNames.any { String requested ->
+ requested == 'pitest'
+ || requested == "${project.path}:pitest"
Review Comment:
Covered by the TestKit fixture in 95f25fe0cb
(`GrailsCodeAnalysisPluginSpec`, 'PITest auto-enables on requested task ...
kills mutants in Spock with configuration cache'). It builds a small project
with Java and static Groovy production classes and a Spock spec, runs the
scoped `:selected:pitest` with `--configuration-cache`, asserts `mutations.xml`
contains KILLED mutants in `add`, `multiply` and the handwritten `getProperty`,
and asserts a second run reports 'Configuration cache entry reused'.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]