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

Introduce mutation test script for changed code #757

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-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-pulls]: https://github.com/PicnicSupermarket/error-prone-support/pulls
23 changes: 23 additions & 0 deletions run-branch-mutation-tests.sh
Original file line number Diff line number Diff line change
@@ -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]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to have something like opt: in here right? In case of optional arguments we internally usually do:
<opt: diff-spec>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we don't do it for the other, but now we worked a lot more with bash so we made some improvements here and there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, square brackets represent optionality; this alternative is less idiomatic IMHO.

exit 1
fi

diffSpec="${1:-+GIT(from[refs/remotes/origin/HEAD])}"

mvn clean test-compile pitest:mutationCoverage \
-DargLine.xmx=2048m \
-Dverification.skip \
-Dfeatures="${diffSpec}"
4 changes: 1 addition & 3 deletions run-mutation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ fi

targetTests="${1:-*}"

mvn clean test pitest:mutationCoverage \
mvn clean test-compile pitest:mutationCoverage \
-DargLine.xmx=2048m \
-Dverification.skip \
-Dsurefire.failIfNoSpecifiedTests=false \
-Dtest="${targetTests}" \
-DtargetTests="${targetTests}"