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

minor: extract maven execution from pitest #11763

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 32 additions & 39 deletions .ci/pitest.sh
Expand Up @@ -7,32 +7,38 @@ function checkPitestReport() {
local -n ignored=$1
fail=0
SEARCH_REGEXP="(span class='survived'|class='uncovered'><pre>)"
grep -irE "$SEARCH_REGEXP" target/pit-reports \
| sed -E 's/.*\/([A-Za-z]+.java.html)/\1/' | LC_ALL=C sort > target/actual.txt
printf "%s\n" "${ignored[@]}" | sed '/^$/d' | LC_ALL=C sort > target/ignored.txt
if [ -n "$2" ] ; then
local -n unstableMutations=$2
printf "%s\n" "${unstableMutations[@]}" | sed '/^$/d' | LC_ALL=C sort > target/unstable.txt
if grep -Fxf target/unstable.txt target/actual.txt > target/unstableMatching.txt ; then
echo "Following unstable mutations were encountered:"
cat target/unstableMatching.txt
grep -xvFf target/unstableMatching.txt target/actual.txt > target/tempActual.txt
cat target/tempActual.txt > target/actual.txt
fi;
fi;
if [ "$(diff --unified -w target/ignored.txt target/actual.txt)" != "" ] ; then
fail=1
echo "Actual:" ;
grep -irE "$SEARCH_REGEXP" target/pit-reports \
| sed -E 's/.*\/([A-Za-z]+.java.html)/\1/' | sort
echo "Ignore:" ;
printf '%s\n' "${ignored[@]}"
echo "Diff:"
diff --unified -w target/ignored.txt target/actual.txt | cat
fi;
if [ "$fail" -ne "0" ]; then
echo "Difference between 'Actual' and 'Ignore' lists is detected, lists should be equal."
echo "build will be failed."
PIT_REPORTS_DIRECTORY="target/pit-reports"
if [ -d "$PIT_REPORTS_DIRECTORY" ]; then
grep -irE "$SEARCH_REGEXP" "$PIT_REPORTS_DIRECTORY" \
| sed -E 's/.*\/([A-Za-z]+.java.html)/\1/' | LC_ALL=C sort > target/actual.txt
printf "%s\n" "${ignored[@]}" | sed '/^$/d' | LC_ALL=C sort > target/ignored.txt
if [ -n "$2" ] ; then
local -n unstableMutations=$2
printf "%s\n" "${unstableMutations[@]}" | sed '/^$/d' | LC_ALL=C sort > target/unstable.txt
if grep -Fxf target/unstable.txt target/actual.txt > target/unstableMatching.txt ; then
echo "Following unstable mutations were encountered:"
cat target/unstableMatching.txt
grep -xvFf target/unstableMatching.txt target/actual.txt > target/tempActual.txt
cat target/tempActual.txt > target/actual.txt
fi;
fi;
if [ "$(diff --unified -w target/ignored.txt target/actual.txt)" != "" ] ; then
fail=1
echo "Actual:" ;
grep -irE "$SEARCH_REGEXP" "$PIT_REPORTS_DIRECTORY" \
| sed -E 's/.*\/([A-Za-z]+.java.html)/\1/' | sort
echo "Ignore:" ;
printf '%s\n' "${ignored[@]}"
echo "Diff:"
diff --unified -w target/ignored.txt target/actual.txt | cat
fi;
if [ "$fail" -ne "0" ]; then
echo "Difference between 'Actual' and 'Ignore' lists is detected, lists should be equal."
echo "build will be failed."
fi
else
fail=1
echo "No pit-reports directory found"
fi
sleep 5s
exit $fail
Expand All @@ -53,21 +59,18 @@ pitest-annotation|pitest-design \
|pitest-tree-walker \
|pitest-utils \
|pitest-java-ast-visitor)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=();
checkPitestReport ignoredItems
;;

pitest-main)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"Main.java.html:<td class='uncovered'><pre><span class=''> }</span></pre></td></tr>"
);
checkPitestReport ignoredItems
;;

pitest-header)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"RegexpHeaderCheck.java.html:<td class='covered'><pre><span class='survived'> isMatch = headerLineNo == headerSize</span></pre></td></tr>"
"RegexpHeaderCheck.java.html:<td class='covered'><pre><span class='survived'> || isMatch(line, headerLineNo);</span></pre></td></tr>"
Expand All @@ -76,7 +79,6 @@ pitest-header)
;;

pitest-imports)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"ImportControlLoader.java.html:<td class='covered'><pre><span class='survived'> else if (ALLOW_ELEMENT_NAME.equals(qName) || &#34;disallow&#34;.equals(qName)) {</span></pre></td></tr>"
"PkgImportControl.java.html:<td class='covered'><pre><span class='survived'> if (regex || parent.regex) {</span></pre></td></tr>"
Expand All @@ -86,7 +88,6 @@ pitest-imports)
;;

pitest-common)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"Checker.java.html:<td class='covered'><pre><span class='survived'> if (cacheFile != null &#38;&#38; cacheFile.isInCache(fileName, timestamp)</span></pre></td></tr>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> closeError = errorStreamOptions == OutputStreamOptions.CLOSE;</span></pre></td></tr>"
Expand All @@ -103,7 +104,6 @@ pitest-common)


pitest-ant)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> if (toFile == null || !useFile) {</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> if (toFile == null || !useFile) {</span></pre></td></tr>"
Expand All @@ -115,7 +115,6 @@ pitest-ant)
;;

pitest-indentation)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"AbstractExpressionHandler.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; curNode.getColumnNo() &#60; realStart.getColumnNo()) {</span></pre></td></tr>"
"AbstractExpressionHandler.java.html:<td class='covered'><pre><span class='survived'> if (colNum == null || thisLineColumn &#60; colNum) {</span></pre></td></tr>"
Expand Down Expand Up @@ -145,7 +144,6 @@ pitest-indentation)
;;

pitest-javadoc)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"AbstractJavadocCheck.java.html:<td class='covered'><pre><span class='survived'> beginJavadocTree(root);</span></pre></td></tr>"
"AbstractJavadocCheck.java.html:<td class='covered'><pre><span class='survived'> finishJavadocTree(root);</span></pre></td></tr>"
Expand All @@ -155,7 +153,6 @@ pitest-javadoc)
;;

pitest-coding-1)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"UnnecessaryParenthesesCheck.java.html:<td class='covered'><pre><span class='survived'> || parent.getType() != TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {</span></pre></td></tr>"
"UnnecessaryParenthesesCheck.java.html:<td class='covered'><pre><span class='survived'> else if (type != TokenTypes.ASSIGN</span></pre></td></tr>"
Expand All @@ -177,7 +174,6 @@ pitest-coding-1)
;;

pitest-coding-2)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"FinalLocalVariableCheck.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; isSameVariables(storedVariable, variable)</span></pre></td></tr>"
"FinalLocalVariableCheck.java.html:<td class='covered'><pre><span class='survived'> == ast.getParent()) {</span></pre></td></tr>"
Expand All @@ -203,7 +199,6 @@ pitest-coding-2)
;;

pitest-coding-require-this-check)
mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"RequireThisCheck.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; ast.getParent().getType() != TokenTypes.LITERAL_CATCH) {</span></pre></td></tr>"
"RequireThisCheck.java.html:<td class='covered'><pre><span class='survived'> if (isAnonymousClassDef(ast)) {</span></pre></td></tr>"
Expand Down Expand Up @@ -241,5 +236,3 @@ pitest-coding-require-this-check)
;;

esac


4 changes: 4 additions & 0 deletions .github/workflows/pitest.yml
Expand Up @@ -51,6 +51,10 @@ jobs:
key: checkstyle-maven-cache-${{ hashFiles('**/pom.xml') }}
- name: Checkout
uses: actions/checkout@v2
- name: Generate ${{ matrix.profile }} report
run: |
mvn -e --no-transfer-progress -P"${{ matrix.profile }}" clean test-compile \
org.pitest:pitest-maven:mutationCoverage
- name: ${{ matrix.profile }}
run: |
./.ci/pitest.sh ${{ matrix.profile }}
Expand Down