Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for "verbosity" flag, disable spinner by default #321

Merged
merged 4 commits into from
Nov 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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 {
Expand All @@ -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])
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class PitestPlugin implements Plugin<Project> {
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() {
Expand Down Expand Up @@ -155,6 +156,7 @@ class PitestPlugin implements Plugin<Project> {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,32 @@ class PitestPluginExtension {
@Incubating
final SetProperty<String> excludedTestClasses
final SetProperty<String> avoidCallsTo
/**
* <p>If true, verbose logging is enabled (capture minion output, show the spinner, only log at detailed level).</p>
* <p>If false, the value of verbosity is used to determine the verbosity of the output.</p>
* <p>Disabled by default.</p>
*
* @see #verbosity
*/
final Property<Boolean> verbose

/**
* Determines the verbosity of the output. Possible values:
* <ul>
* <li>QUIET (no capture of minion output, no spinner, only log severe errors)</li>
* <li>QUIET_WITH_PROGRESS (no capture of minion output, show the spinner, only log severe errors)</li>
* <li>DEFAULT (no capture of minion output, show the spinner, only log at info level)</li>
* <li>NO_SPINNER (no capture of minion output, no spinner, only log at info level)</li>
* <li>VERBOSE_NO_SPINNER (capture minion output, no spinner, only log at detailed level)</li>
* <li>VERBOSE (capture minion output, show the spinner, only log at detailed level)</li>
* </ul>
* <p>The default value used by the plugin is NO_SPINNER (not DEFAULT, despite the name).</p>
* <p><b>Note:</b> verbose must be set to false (which is the default) for this to have an effect.</p>
*
* @see #verbose
* @since 1.9.1
*/
final Property<String> verbosity //new in PIT 1.7.1 (GPP 1.9.1)
final Property<BigDecimal> timeoutFactor
final Property<Integer> timeoutConstInMillis
/**
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class PitestTask extends JavaExec {
@Optional
final Property<Boolean> verbose

@Input
@Optional
final Property<String> verbosity

@Input
@Optional
final Property<BigDecimal> timeoutFactor
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
szpak marked this conversation as resolved.
Show resolved Hide resolved
}

void "should not pass to PIT parameter '#paramName' by default if not set explicitly"() {
Expand All @@ -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:
Expand Down