diff --git a/.ci/pitest.sh b/.ci/pitest.sh index 41c086adb4e..6807d452331 100755 --- a/.ci/pitest.sh +++ b/.ci/pitest.sh @@ -7,32 +7,38 @@ function checkPitestReport() { local -n ignored=$1 fail=0 SEARCH_REGEXP="(span class='survived'|class='uncovered'>
)" - 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 @@ -53,13 +59,11 @@ 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:" ); @@ -67,7 +71,6 @@ pitest-main) ;; pitest-header) - mvn -e --no-transfer-progress -P"$1" clean test-compile org.pitest:pitest-maven:mutationCoverage; declare -a ignoredItems=( "RegexpHeaderCheck.java.html: }
" "RegexpHeaderCheck.java.html: isMatch = headerLineNo == headerSize
" @@ -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: || isMatch(line, headerLineNo);
" "PkgImportControl.java.html: else if (ALLOW_ELEMENT_NAME.equals(qName) || "disallow".equals(qName)) {
" @@ -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: if (regex || parent.regex) {
" "DefaultLogger.java.html: if (cacheFile != null && cacheFile.isInCache(fileName, timestamp)
" @@ -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: closeError = errorStreamOptions == OutputStreamOptions.CLOSE;
" "CheckstyleAntTask.java.html: if (toFile == null || !useFile) {
" @@ -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: if (toFile == null || !useFile) {
" "AbstractExpressionHandler.java.html: && curNode.getColumnNo() < realStart.getColumnNo()) {
" @@ -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: if (colNum == null || thisLineColumn < colNum) {
" "AbstractJavadocCheck.java.html: beginJavadocTree(root);
" @@ -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: finishJavadocTree(root);
" "UnnecessaryParenthesesCheck.java.html: || parent.getType() != TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
" @@ -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: else if (type != TokenTypes.ASSIGN
" "FinalLocalVariableCheck.java.html: && isSameVariables(storedVariable, variable)
" @@ -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: == ast.getParent()) {
" "RequireThisCheck.java.html: && ast.getParent().getType() != TokenTypes.LITERAL_CATCH) {
" @@ -241,5 +236,3 @@ pitest-coding-require-this-check) ;; esac - - diff --git a/.github/workflows/pitest.yml b/.github/workflows/pitest.yml index 248607142a6..dcda6867fac 100644 --- a/.github/workflows/pitest.yml +++ b/.github/workflows/pitest.yml @@ -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 }} if (isAnonymousClassDef(ast)) {