diff --git a/README.md b/README.md index 469adea4..e0cf4bde 100644 --- a/README.md +++ b/README.md @@ -77,14 +77,14 @@ pitest { The configuration in Gradle is the real Groovy code which makes all assignments very intuitive. All values expected by PIT should be passed as a corresponding types. There is only one important difference. For the parameters where PIT expects a coma separated list of strings in a Gradle configuration a list of strings should be used (see `outputFormats` in the -following example). +example above). Check PIT documentation for a [list](https://pitest.org/quickstart/commandline/) of all available command line parameters. The expected parameter format in a plugin configuration can be taken from [PitestPluginExtension](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy). -To make life easier `taskClasspath`, `mutableCodePaths`, `sourceDirs`, `reportDir` and `pitestVersion` are -automatically set by a plugin. In addition `sourceDirs`, `reportDir` and `pitestVersion` can be overridden by an user. +To make life easier `taskClasspath`, `mutableCodePaths`, `sourceDirs`, `reportDir`, `verbosity` and `pitestVersion` are +automatically set by the plugin. In addition `sourceDirs`, `reportDir`, `verbosity` and `pitestVersion` can be overridden by a user. There are a few parameters specific for Gradle plugin: @@ -113,7 +113,7 @@ pitest { ### Test system properties -PIT executes tests in a JVM independent from the JVM used by Gradle to execute tests. If your tests require some system properties, you have to pass them to PIT as the plugin won't do it for you: +PIT executes tests in a JVM independent of the JVM used by Gradle to execute tests. If your tests require some system properties, you have to pass them to PIT as the plugin won't do it for you: ```groovy test { @@ -127,7 +127,7 @@ pitest { ### Eliminate warning in Idea -As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) Idea displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. It is not a real problem as Gradle internally intercepts those calls and use a setter instead . Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: +As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) IntelliJ IDEA displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. It is not a real problem as Gradle internally intercepts those calls and use a setter instead . Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: ```groovy testSourceSets.set([sourceSets.test, sourceSets.integrationTest]) @@ -287,7 +287,7 @@ Please note. Starting with PIT 1.6.7 it is no longer needed to set `testPlugin` ## Versions -Every gradle-pitest-plugin version by default uses a predefined PIT version. Usually this a the latest released version +Every gradle-pitest-plugin version by default uses a predefined PIT version. Usually this the latest released version of PIT available at the time of releasing a plugin version. It can be overridden by using `pitestVersion` parameter in a `pitest` configuration closure. @@ -318,16 +318,16 @@ After [applied](https://github.com/nebula-plugins/gradle-override-plugin) gradle ./gradlew pitest -Doverride.pitest.reportDir=build/pitReport -Doverride.pitest.threads=8 -Note. The mechanism should work fine for String and numeric properties, but the are limitations with support of +Note. The mechanism should work fine for String and numeric properties, but there are limitations with support of [Lists/Sets/Maps](https://github.com/nebula-plugins/gradle-override-plugin/issues/3) and [Boolean values](https://github.com/nebula-plugins/gradle-override-plugin/issues/1). For more information see project [web page](https://github.com/nebula-plugins/gradle-override-plugin). ### How can I change PIT version from default to just released the newest one? -gradle-pitest-plugin by default uses a corresponsing PIT version (with the same number). The plugin is released only if there are internal changes or +gradle-pitest-plugin by default uses a corresponding PIT version (with the same number). The plugin is released only if there are internal changes or there is a need to adjust to changes in newer PIT version. There is a dedicated mechanism to allow to use the latest PIT version (e.g, a bugfix release) -or to downgrade PIT in case of detected issues. To override a defalt version it is enough to set `pitestVersion` property in the `pitest` configuration +or to downgrade PIT in case of detected issues. To override a default version it is enough to set `pitestVersion` property in the `pitest` configuration closure. ```groovy @@ -350,7 +350,7 @@ pitest { ### How can I debug a gradle-pitest-plugin execution or a PIT process execution itself in a Gradle build? -Ocasionally, it may be useful to debug a gradle-pitest-plugin execution or a PIT execution itself (e.g. [NPE in PIT](https://github.com/hcoles/pitest/issues/345)) to provide sensible error report. +Occasionally, it may be useful to debug a gradle-pitest-plugin execution or a PIT execution itself (e.g. [NPE in PIT](https://github.com/hcoles/pitest/issues/345)) to provide sensible error report. The gradle-pitest-plugin execution can be remotely debugged with adding `-Dorg.gradle.debug=true` to the command line. @@ -375,7 +375,7 @@ gradle-pitest plugin [1.5.0](https://github.com/szpak/gradle-pitest-plugin/relea ## Known issues - - too verbose output from PIT + - too verbose output from PIT (also see `verbosity` option introduced with PIT 1.7.1) ## Development diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy index 9ac192d5..6d0f8531 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy @@ -3,14 +3,12 @@ package info.solidsoft.gradle.pitest.functional import groovy.transform.CompileDynamic import info.solidsoft.gradle.pitest.PitestPlugin import nebula.test.functional.ExecutionResult -import org.gradle.internal.jvm.Jvm @SuppressWarnings("GrMethodMayBeStatic") @CompileDynamic class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final String MINIMAL_SUPPORTED_PIT_VERSION = "1.4.1" //minimal PIT version that works with Java 11 - Aug 2018 - private static final String MINIMAL_JAVA17_COMPATIBLE_PIT_VERSION = "1.6.8" + private static final String MINIMAL_SUPPORTED_PIT_VERSION = "1.7.1" //minimal PIT version that includes verbosity flag - Sep 2021 void "setup and run pitest task with PIT #pitVersion"() { given: @@ -45,11 +43,7 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec } private String getMinimalPitVersionCompatibleWithCurrentJavaVersion() { - if (Jvm.current().javaVersion.isJava12Compatible()) { - return MINIMAL_JAVA17_COMPATIBLE_PIT_VERSION //safe modern version - } else { - return MINIMAL_SUPPORTED_PIT_VERSION //minimal supported PIT version only for testing with Java <12, due to JVM compatibility issues - } + return MINIMAL_SUPPORTED_PIT_VERSION } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 7b23330c..4ce4b91b 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -112,6 +112,7 @@ class PitestPlugin implements Plugin { extension.mainSourceSets.set([javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)]) extension.fileExtensionsToFilter.set(DEFAULT_FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH) extension.useClasspathFile.set(false) + extension.verbosity.set("NO_SPINNER") } private void failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() { @@ -155,6 +156,7 @@ class PitestPlugin implements Plugin { task.excludedTestClasses.set(extension.excludedTestClasses) task.avoidCallsTo.set(extension.avoidCallsTo) task.verbose.set(extension.verbose) + task.verbosity.set(extension.verbosity) task.timeoutFactor.set(extension.timeoutFactor) task.timeoutConstInMillis.set(extension.timeoutConstInMillis) task.childProcessJvmArgs.set(extension.jvmArgs) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 722398c4..5cd0fefa 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -89,7 +89,32 @@ class PitestPluginExtension { @Incubating final SetProperty excludedTestClasses final SetProperty avoidCallsTo + /** + *

If true, verbose logging is enabled (capture minion output, show the spinner, only log at detailed level).

+ *

If false, the value of verbosity is used to determine the verbosity of the output.

+ *

Disabled by default.

+ * + * @see #verbosity + */ final Property verbose + + /** + * Determines the verbosity of the output. Possible values: + *
    + *
  • QUIET (no capture of minion output, no spinner, only log severe errors)
  • + *
  • QUIET_WITH_PROGRESS (no capture of minion output, show the spinner, only log severe errors)
  • + *
  • DEFAULT (no capture of minion output, show the spinner, only log at info level)
  • + *
  • NO_SPINNER (no capture of minion output, no spinner, only log at info level)
  • + *
  • VERBOSE_NO_SPINNER (capture minion output, no spinner, only log at detailed level)
  • + *
  • VERBOSE (capture minion output, show the spinner, only log at detailed level)
  • + *
+ *

The default value used by the plugin is NO_SPINNER (not DEFAULT, despite the name).

+ *

Note: verbose must be set to false (which is the default) for this to have an effect.

+ * + * @see #verbose + * @since 1.9.1 + */ + final Property verbosity //new in PIT 1.7.1 (GPP 1.9.1) final Property timeoutFactor final Property timeoutConstInMillis /** @@ -237,6 +262,7 @@ class PitestPluginExtension { excludedTestClasses = nullSetPropertyOf(p, String) avoidCallsTo = nullSetPropertyOf(p, String) verbose = of.property(Boolean) + verbosity = of.property(String) timeoutFactor = of.property(BigDecimal) timeoutConstInMillis = of.property(Integer) jvmArgs = nullListPropertyOf(p, String) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index acd2dbff..311b4ad2 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -94,6 +94,10 @@ class PitestTask extends JavaExec { @Optional final Property verbose + @Input + @Optional + final Property verbosity + @Input @Optional final Property timeoutFactor @@ -261,6 +265,7 @@ class PitestTask extends JavaExec { excludedTestClasses = of.setProperty(String) avoidCallsTo = of.setProperty(String) verbose = of.property(Boolean) + verbosity = of.property(String) timeoutFactor = of.property(BigDecimal) timeoutConstInMillis = of.property(Integer) childProcessJvmArgs = of.listProperty(String) @@ -350,6 +355,7 @@ class PitestTask extends JavaExec { map['excludedTestClasses'] = optionalCollectionAsString(excludedTestClasses) map['avoidCallsTo'] = optionalCollectionAsString(avoidCallsTo) map['verbose'] = optionalPropertyAsString(verbose) + map['verbosity'] = optionalPropertyAsString(verbosity) map['timeoutFactor'] = optionalPropertyAsString(timeoutFactor) map['timeoutConst'] = optionalPropertyAsString(timeoutConstInMillis) map['jvmArgs'] = optionalCollectionAsString(childProcessJvmArgs) diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index a7ead0e2..c15e004c 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -113,7 +113,7 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit void "should not pass features configuration to PIT if not set in configuration or via option"() { //Intentional duplication with generic parametrized tests to emphasis requirement expect: - task.taskArgumentMap()['featues'] == null + task.taskArgumentMap()['features'] == null } void "should not pass to PIT parameter '#paramName' by default if not set explicitly"() { @@ -124,6 +124,19 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit paramName << PIT_PARAMETERS_NAMES_NOT_SET_BY_DEFAULT } + void "should pass to PIT parameter 'verbosity' by default if not set explicitly"() { + expect: + task.taskArgumentMap().containsKey('verbosity') + task.taskArgumentMap().get('verbosity').is('NO_SPINNER') + } + + void "should pass to PIT parameter 'verbosity' if set explicitly"() { + given: + project.pitest.verbosity = 'QUIET_WITH_PROGRESS' + expect: + task.taskArgumentMap().get('verbosity').is('QUIET_WITH_PROGRESS') + } + //TODO: Run PIT with those values to detect removed properties and typos void "should pass plugin configuration (#configParamName) from Gradle to PIT"() { given: