Introduce mutation test script for changed code (#757)

While there, optimize the existing `run-mutation-tests.sh` script.
This commit is contained in:
Stephan Schroevers
2023-08-28 10:43:06 +03:00
committed by GitHub
parent 9c158f11d4
commit 6131599d9d
4 changed files with 33 additions and 8 deletions

View File

@@ -80,6 +80,6 @@ Some pointers:
[error-prone-support-developing]: https://github.com/PicnicSupermarket/error-prone-support/tree/master#-developing-error-prone-support [error-prone-support-developing]: https://github.com/PicnicSupermarket/error-prone-support/tree/master#-developing-error-prone-support
[error-prone-support-full-build]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-full-build.sh [error-prone-support-full-build]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-full-build.sh
[error-prone-support-issues]: https://github.com/PicnicSupermarket/error-prone-support/issues [error-prone-support-issues]: https://github.com/PicnicSupermarket/error-prone-support/issues
[error-prone-support-mutation-tests]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-mutation-tests.sh [error-prone-support-mutation-tests]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-branch-mutation-tests.sh
[error-prone-support-patch]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/apply-error-prone-suggestions.sh [error-prone-support-patch]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/apply-error-prone-suggestions.sh
[error-prone-support-pulls]: https://github.com/PicnicSupermarket/error-prone-support/pulls [error-prone-support-pulls]: https://github.com/PicnicSupermarket/error-prone-support/pulls

View File

@@ -223,10 +223,13 @@ Other highly relevant commands:
Before running this command, make sure to have installed the project (`mvn Before running this command, make sure to have installed the project (`mvn
clean install`) and make sure that the current working directory does not clean install`) and make sure that the current working directory does not
contain unstaged or uncommited changes. contain unstaged or uncommited changes.
- [`./run-mutation-tests.sh`][script-run-mutation-tests] runs mutation tests - [`./run-branch-mutation-tests.sh`][script-run-branch-mutation-tests] uses
using [Pitest][pitest]. The results can be reviewed by opening the respective [Pitest][pitest] to run mutation tests against code that is modified relative
`target/pit-reports/index.html` files. For more information check the [PIT to the upstream default branch. The results can be reviewed by opening the
Maven plugin][pitest-maven]. respective `target/pit-reports/index.html` files. One can use
[`./run-mutation-tests.sh`][script-run-mutation-tests] to run mutation tests
against _all_ code in the current working directory. For more information
check the [PIT Maven plugin][pitest-maven].
When running the project's tests in IntelliJ IDEA, you might see the following When running the project's tests in IntelliJ IDEA, you might see the following
error: error:
@@ -296,6 +299,7 @@ channel; please see our [security policy][security] for details.
[reproducible-builds-badge]: https://img.shields.io/badge/Reproducible_Builds-ok-success?labelColor=1e5b96 [reproducible-builds-badge]: https://img.shields.io/badge/Reproducible_Builds-ok-success?labelColor=1e5b96
[reproducible-builds-report]: https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/tech/picnic/error-prone-support/error-prone-support/README.md [reproducible-builds-report]: https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/tech/picnic/error-prone-support/error-prone-support/README.md
[script-apply-error-prone-suggestions]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/apply-error-prone-suggestions.sh [script-apply-error-prone-suggestions]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/apply-error-prone-suggestions.sh
[script-run-branch-mutation-tests]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-branch-mutation-tests.sh
[script-run-full-build]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-full-build.sh [script-run-full-build]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-full-build.sh
[script-run-mutation-tests]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-mutation-tests.sh [script-run-mutation-tests]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/run-mutation-tests.sh
[security]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/SECURITY.md [security]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/SECURITY.md

23
run-branch-mutation-tests.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Executes Pitest to determine the mutation test coverage of changed code. By
# default code that is changed relative to the default branch is exercised,
# though another change set may be specified; see the Arcmutate Git integration
# documentation for details [1]. The results are found in each Maven module's
# `target/pit-reports` directory.
#
# [1] https://docs.arcmutate.com/docs/git-integration.html
set -e -u -o pipefail
if [ "${#}" -gt 1 ]; then
echo "Usage: ${0} [DiffSpec]"
exit 1
fi
diffSpec="${1:-+GIT(from[refs/remotes/origin/HEAD])}"
mvn clean test-compile pitest:mutationCoverage \
-DargLine.xmx=2048m \
-Dverification.skip \
-Dfeatures="${diffSpec}"

View File

@@ -13,9 +13,7 @@ fi
targetTests="${1:-*}" targetTests="${1:-*}"
mvn clean test pitest:mutationCoverage \ mvn clean test-compile pitest:mutationCoverage \
-DargLine.xmx=2048m \ -DargLine.xmx=2048m \
-Dverification.skip \ -Dverification.skip \
-Dsurefire.failIfNoSpecifiedTests=false \
-Dtest="${targetTests}" \
-DtargetTests="${targetTests}" -DtargetTests="${targetTests}"