-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
pitest.sh
executable file
·163 lines (147 loc) · 10.3 KB
/
pitest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
# Attention, there is no "-x" to avoid problems on Wercker
set -e
###############################
function checkPitestReport() {
ignored=("$@")
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 [ "$(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."
fi
sleep 5s
exit $fail
}
###############################
case $1 in
pitest-annotation|pitest-design \
|pitest-metrics|pitest-modifier|pitest-naming \
|pitest-sizes|pitest-whitespace \
|pitest-api|pitest-blocks \
|pitest-packagenamesloader \
|pitest-common-2|pitest-misc|pitest-xpath \
|pitest-filters \
|pitest-coding \
|pitest-regexp \
|pitest-meta \
|pitest-tree-walker \
|pitest-utils \
|pitest-java-ast-visitor)
mvn --no-transfer-progress -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=();
checkPitestReport "${ignoredItems[@]}"
;;
# till #9351
pitest-main)
mvn --no-transfer-progress -e -P$1 clean test 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 --no-transfer-progress -e -P$1 clean test 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>"
);
checkPitestReport "${ignoredItems[@]}"
;;
pitest-imports)
mvn --no-transfer-progress -e -P$1 clean test 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) || "disallow".equals(qName)) {</span></pre></td></tr>"
"PkgImportControl.java.html:<td class='covered'><pre><span class='survived'> if (regex || parent.regex) {</span></pre></td></tr>"
"PkgImportControl.java.html:<td class='covered'><pre><span class='survived'> if (regex) {</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
pitest-common)
mvn --no-transfer-progress -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"AuditEventDefaultFormatter.java.html:<td class='covered'><pre><span class='survived'> if (lastDotIndex == -1) {</span></pre></td></tr>"
"Checker.java.html:<td class='covered'><pre><span class='survived'> if (cacheFile != null && 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>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> closeInfo = infoStreamOptions == OutputStreamOptions.CLOSE;</span></pre></td></tr>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> if (closeError) {</span></pre></td></tr>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> if (closeInfo) {</span></pre></td></tr>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> if (severityLevel != SeverityLevel.IGNORE) {</span></pre></td></tr>"
"PackageObjectFactory.java.html:<td class='covered'><pre><span class='survived'> if (instance == null</span></pre></td></tr>"
"PackageObjectFactory.java.html:<td class='covered'><pre><span class='survived'> if (!name.contains(PACKAGE_SEPARATOR)) {</span></pre></td></tr>"
"PackageObjectFactory.java.html:<td class='covered'><pre><span class='survived'> if (thirdPartyNameToFullModuleNames == null) {</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
pitest-ant)
mvn --no-transfer-progress -e -P$1 clean test 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>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log("To process the files took " + (processingEndTime - processingStartTime)</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log("Total execution took " + (endTime - startTime) + TIME_SUFFIX,</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log("To locate the files took " + (endTime - startTime) + TIME_SUFFIX,</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
pitest-indentation)
mvn --no-transfer-progress -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"AbstractExpressionHandler.java.html:<td class='covered'><pre><span class='survived'> && curNode.getColumnNo() < realStart.getColumnNo()) {</span></pre></td></tr>"
"AbstractExpressionHandler.java.html:<td class='covered'><pre><span class='survived'> if (colNum == null || thisLineColumn < colNum) {</span></pre></td></tr>"
"AbstractExpressionHandler.java.html:<td class='covered'><pre><span class='survived'> if (toTest.getColumnNo() < first.getColumnNo()) {</span></pre></td></tr>"
"BlockParentHandler.java.html:<td class='covered'><pre><span class='survived'> return getIndentCheck().getLineWrappingIndentation();</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> && root.getFirstChild().getFirstChild().getFirstChild().getNextSibling() != null;</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> if (isUsingOfObjectReferenceToInvokeMethod(blockBody)) {</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> if (isUsingOfObjectReferenceToInvokeMethod(root)) {</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> if (root.getFirstChild().getType() == TokenTypes.LITERAL_NEW) {</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> if (root.getLineNo() >= comment.getLineNo()) {</span></pre></td></tr>"
"CommentsIndentationCheck.java.html:<td class='covered'><pre><span class='survived'> return root.getFirstChild().getFirstChild().getFirstChild() != null</span></pre></td></tr>"
"HandlerFactory.java.html:<td class='covered'><pre><span class='survived'> createdHandlers.clear();</span></pre></td></tr>"
"HandlerFactory.java.html:<td class='covered'><pre><span class='survived'> register(TokenTypes.INDEX_OP, IndexHandler.class);</span></pre></td></tr>"
"IndentationCheck.java.html:<td class='covered'><pre><span class='survived'> handlerFactory.clearCreatedHandlers();</span></pre></td></tr>"
"IndentationCheck.java.html:<td class='covered'><pre><span class='survived'> handlers.clear();</span></pre></td></tr>"
"IndentationCheck.java.html:<td class='covered'><pre><span class='survived'> primordialHandler.checkIndentation();</span></pre></td></tr>"
"MethodDefHandler.java.html:<td class='covered'><pre><span class='survived'> if (node.getLineNo() < lineStart) {</span></pre></td></tr>"
"NewHandler.java.html:<td class='covered'><pre><span class='survived'> return false;</span></pre></td></tr>"
"SwitchHandler.java.html:<td class='covered'><pre><span class='survived'> checkExpressionSubtree(</span></pre></td></tr>"
"SwitchHandler.java.html:<td class='covered'><pre><span class='survived'> checkSwitchExpr();</span></pre></td></tr>"
"SynchronizedHandler.java.html:<td class='covered'><pre><span class='survived'> checkExpressionSubtree(syncAst, expected, false, false);</span></pre></td></tr>"
"SynchronizedHandler.java.html:<td class='covered'><pre><span class='survived'> checkSynchronizedExpr();</span></pre></td></tr>"
"SynchronizedHandler.java.html:<td class='covered'><pre><span class='survived'> checkWrappingIndentation(getMainAst(),</span></pre></td></tr>"
"TryHandler.java.html:<td class='covered'><pre><span class='survived'> checkTryResParen(getTryResLparen(), "lparen");</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
pitest-javadoc)
mvn --no-transfer-progress -e -P$1 clean test 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>"
"TagParser.java.html:<td class='covered'><pre><span class='survived'> while (column < currentLine.length()</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
# pitesttyle-gui)
# mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
# # post validation is skipped, we do not test gui throughly
# ;;
*)
echo "Unexpected argument: $1"
sleep 5s
false
;;
esac