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

Issue #6439: move powermock tests away from the normal tests #6445

Merged
merged 2 commits into from Feb 23, 2019
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
77 changes: 74 additions & 3 deletions .ci/pitest.sh
Expand Up @@ -34,8 +34,8 @@ case $1 in
pitest-annotation|pitest-design \
|pitest-metrics|pitest-modifier|pitest-naming \
|pitest-sizes|pitest-whitespace \
|pitest-packagenamesloader|pitest-tree-walker|pitest-utils \
|pitest-common-2|pitest-misc)
|pitest-packagenamesloader \
|pitest-common-2)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=();
checkPitestReport "${ignoredItems[@]}"
Expand All @@ -48,8 +48,10 @@ pitest-xpath)
"ElementNode.java.html:<td class='covered'><pre><span class='survived'> if (hasChildNodes()) {</span></pre></td></tr>"
"RootNode.java.html:<td class='covered'><pre><span class='survived'> if (detailAst != null) {</span></pre></td></tr>"
"XpathFileGeneratorAstFilter.java.html:<td class='covered'><pre><span class='survived'> if (!xpathQueries.isEmpty()) {</span></pre></td></tr>"
"XpathFileGeneratorAuditListener.java.html:<td class='covered'><pre><span class='survived'> writer.close();</span></pre></td></tr>"
"XpathFileGeneratorAuditListener.java.html:<td class='covered'><pre><span class='survived'> closeStream = outputStreamOptions == OutputStreamOptions.CLOSE;</span></pre></td></tr>"
"XpathFileGeneratorAuditListener.java.html:<td class='covered'><pre><span class='survived'> if (closeStream) {</span></pre></td></tr>"
"XpathFileGeneratorAuditListener.java.html:<td class='covered'><pre><span class='survived'> writer.flush();</span></pre></td></tr>"
"XpathQueryGenerator.java.html:<td class='covered'><pre><span class='survived'> if (ast.getParent() == null) {</span></pre></td></tr>"
"XpathQueryGenerator.java.html:<td class='covered'><pre><span class='survived'> if (!result) {</span></pre></td></tr>"
"XpathQueryGenerator.java.html:<td class='covered'><pre><span class='survived'> if (toVisit == null) {</span></pre></td></tr>"
Expand All @@ -72,6 +74,8 @@ pitest-regexp)
pitest-header)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"AbstractHeaderCheck.java.html:<td class='uncovered'><pre><span class=''> catch (final IOException ex) {</span></pre></td></tr>"
"AbstractHeaderCheck.java.html:<td class='uncovered'><pre><span class='survived'> throw new IllegalArgumentException(&#34;unable to load header&#34;, ex);</span></pre></td></tr>"
"HeaderCheck.java.html:<td class='covered'><pre><span class='survived'> if (list.length == 0) {</span></pre></td></tr>"
"RegexpHeaderCheck.java.html:<td class='covered'><pre><span class='survived'> if (list.length == 0) {</span></pre></td></tr>"
"RegexpHeaderCheck.java.html:<td class='covered'><pre><span class='survived'> isMatch = headerLineNo == headerSize</span></pre></td></tr>"
Expand Down Expand Up @@ -117,7 +121,6 @@ pitest-api)
"FileContents.java.html:<td class='covered'><pre><span class='survived'> if (hasIntersection) {</span></pre></td></tr>"
"FileText.java.html:<td class='covered'><pre><span class='survived'> if (lineBreaks == null) {</span></pre></td></tr>"
"FileText.java.html:<td class='covered'><pre><span class='survived'> if (lineNo &#60; lineBreakPositions.length) {</span></pre></td></tr>"
"LocalizedMessage.java.html:<td class='covered'><pre><span class='survived'> connection.setUseCaches(!reload);</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
Expand Down Expand Up @@ -168,17 +171,46 @@ pitest-common)
mvn -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>"
"AuditEventDefaultFormatter.java.html:<td class='uncovered'><pre><span class=''> checkShortName = checkFullName.substring(0, checkFullName.lastIndexOf(SUFFIX));</span></pre></td></tr>"
"AuditEventDefaultFormatter.java.html:<td class='uncovered'><pre><span class=''> checkShortName = checkFullName;</span></pre></td></tr>"
"AuditEventDefaultFormatter.java.html:<td class='uncovered'><pre><span class='survived'> if (checkFullName.endsWith(SUFFIX)) {</span></pre></td></tr>"
"Checker.java.html:<td class='covered'><pre><span class='survived'> if (cacheFile != null &#38;&#38; cacheFile.isInCache(fileName, timestamp)</span></pre></td></tr>"
"Checker.java.html:<td class='covered'><pre><span class='survived'> if (fileName != null &#38;&#38; cacheFile != null) {</span></pre></td></tr>"
"Checker.java.html:<td class='uncovered'><pre><span class=''> catch (Error error) {</span></pre></td></tr>"
"Checker.java.html:<td class='uncovered'><pre><span class='survived'> cacheFile.remove(fileName);</span></pre></td></tr>"
"Checker.java.html:<td class='uncovered'><pre><span class='survived'> if (fileName != null &#38;&#38; cacheFile != null) {</span></pre></td></tr>"
"Checker.java.html:<td class='uncovered'><pre><span class='survived'> throw new Error(&#34;Error was thrown while processing &#34; + file.getPath(), error);</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='covered'><pre><span class='survived'> if (!qName.equals(METADATA)) {</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='covered'><pre><span class='survived'> else if (qName.equals(MESSAGE)) {</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='covered'><pre><span class='survived'> final boolean omitIgnoreModules = ignoredModulesOptions == IgnoredModulesOptions.OMIT;</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 (infoStream == errorStream) {</span></pre></td></tr>"
"DefaultLogger.java.html:<td class='covered'><pre><span class='survived'> if (severityLevel != SeverityLevel.IGNORE) {</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class=''> catch (final CheckstyleException ex) {</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class=''> catch (final ParserConfigurationException | IOException | SAXException ex) {</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class='survived'> + recentModule.getName(), ex);</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class='survived'> throw new SAXException(</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class='survived'> throw new IllegalStateException(&#34;Unknown name:&#34; + qName + &#34;.&#34;);</span></pre></td></tr>"
"ConfigurationLoader.java.html:<td class='uncovered'><pre><span class='survived'> throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, ex);</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>"
"PackageObjectFactory.java.html:<td class='uncovered'><pre><span class=''> returnValue = Collections.emptyMap();</span></pre></td></tr>"
"PackageObjectFactory.java.html:<td class='uncovered'><pre><span class=''> catch (IOException ignore) {</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> if (!cachedHashSum.equals(contentHashSum)) {</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> Flushables.flush(stream, false);</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> flushAndCloseOutStream(oos);</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> flushAndCloseOutStream(out);</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> Closeables.close(stream, false);</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='covered'><pre><span class='survived'> if (stream != null) {</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='uncovered'><pre><span class=''> changed = true;</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='uncovered'><pre><span class=''> catch (IOException ex) {</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='uncovered'><pre><span class=''> catch (final IOException | NoSuchAlgorithmException ex) {</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='uncovered'><pre><span class='survived'> throw new CheckstyleException(&#34;Unable to load external resource file &#34; + location, ex);</span></pre></td></tr>"
"PropertyCacheFile.java.html:<td class='uncovered'><pre><span class='survived'> throw new IllegalStateException(&#34;Unable to calculate hashcode.&#34;, ex);</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
Expand All @@ -189,6 +221,12 @@ pitest-ant)
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(&#34;Adding standalone file for audit&#34;, Project.MSG_VERBOSE);</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log(&#34;To process the files took &#34; + (processingEndTime - processingStartTime)</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log(&#34;Total execution took &#34; + (endTime - startTime) + TIME_SUFFIX,</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='covered'><pre><span class='survived'> log(&#34;To locate the files took &#34; + (endTime - startTime) + TIME_SUFFIX,</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='uncovered'><pre><span class=''> catch (CheckstyleException ex) {</span></pre></td></tr>"
"CheckstyleAntTask.java.html:<td class='uncovered'><pre><span class='survived'> throw new BuildException(&#34;Unable to process files: &#34; + files, ex);</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;
Expand Down Expand Up @@ -265,13 +303,46 @@ pitest-javadoc)
"AbstractTypeAwareCheck.java.html:<td class='covered'><pre><span class='survived'> if (dotIdx == -1) {</span></pre></td></tr>"
"AbstractTypeAwareCheck.java.html:<td class='covered'><pre><span class='survived'> imports.clear();</span></pre></td></tr>"
"AbstractTypeAwareCheck.java.html:<td class='covered'><pre><span class='survived'> typeParams.clear();</span></pre></td></tr>"
"ClassResolver.java.html:<td class='uncovered'><pre><span class=''> catch (final ClassNotFoundException ex) {</span></pre></td></tr>"
"ClassResolver.java.html:<td class='uncovered'><pre><span class='survived'> throw new IllegalStateException(ex);</span></pre></td></tr>"
"JavadocTagInfo.java.html:<td class='covered'><pre><span class='survived'> .collect(Collectors.toMap(JavadocTagInfo::getName, tagName -&#62; tagName)));</span></pre></td></tr>"
"JavadocTagInfo.java.html:<td class='covered'><pre><span class='survived'> .collect(Collectors.toMap(JavadocTagInfo::getText, tagText -&#62; tagText)));</span></pre></td></tr>"
"TagParser.java.html:<td class='covered'><pre><span class='survived'> while (column &#60; currentLine.length()</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;

pitest-tree-walker)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"TreeWalker.java.html:<td class='covered'><pre><span class='survived'> if (!commentChecks.isEmpty()) {</span></pre></td></tr>"
"TreeWalker.java.html:<td class='covered'><pre><span class='survived'> if (!ordinaryChecks.isEmpty()) {</span></pre></td></tr>"
"TreeWalker.java.html:<td class='covered'><pre><span class='survived'> if (filters.isEmpty()) {</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;

pitest-misc)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"TranslationCheck.java.html:<td class='covered'><pre><span class='survived'> if (exception instanceof NoSuchFileException) {</span></pre></td></tr>"
"TranslationCheck.java.html:<td class='uncovered'><pre><span class=''> args = null;</span></pre></td></tr>"
"TranslationCheck.java.html:<td class='uncovered'><pre><span class=''> key = &#34;general.fileNotFound&#34;;</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;

pitest-utils)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"CommonUtil.java.html:<td class='uncovered'><pre><span class=''> uri = configUrl.toURI();</span></pre></td></tr>"
"CommonUtil.java.html:<td class='uncovered'><pre><span class=''> catch (final URISyntaxException ex) {</span></pre></td></tr>"
"CommonUtil.java.html:<td class='uncovered'><pre><span class=''> }</span></pre></td></tr>"
"CommonUtil.java.html:<td class='uncovered'><pre><span class='survived'> throw new CheckstyleException(UNABLE_TO_FIND_EXCEPTION_PREFIX + filename, ex);</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
Expand Down
7 changes: 7 additions & 0 deletions config/import-control-test.xml
Expand Up @@ -7,6 +7,13 @@

<disallow pkg="junit.framework" />

<!-- Conflicts with normal tests and pitest.
See examples in https://github.com/checkstyle/checkstyle/issues/6439 -->
<allow class="org.powermock.reflect.Whitebox" />
<allow class="org.mockito.internal.util.Checks" />
Copy link
Member Author

Choose a reason for hiding this comment

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

These are ok since they use reflection and not byte code hacking.

<disallow pkg="org\.powermock.*" regex="true" />
<disallow pkg="org\.mockito.*" regex="true" />

<allow pkg=".*" regex="true" />

</import-control>
4 changes: 3 additions & 1 deletion config/suppressions.xml
Expand Up @@ -79,7 +79,7 @@
files="(Checker|Main|CheckstyleAntTask|JavadocDetailNodeParser)\.java"/>
<suppress checks="ClassDataAbstractionCoupling"
files="(CheckerTest|AbstractModuleTestSupport|CheckstyleAntTaskTest|
|TranslationCheckTest)\.java"/>
|TranslationCheckTest|LocalizedMessageTest)\.java"/>
<suppress checks="ClassDataAbstractionCoupling" files="PropertyCacheFileTest\.java"/>
<suppress checks="ClassDataAbstractionCoupling"
files="XpathFileGeneratorAuditListenerTest\.java"/>
Expand All @@ -97,4 +97,6 @@

<!-- HandlerFactory crosses allowed limit for executable statements -->
<suppress checks="ExecutableStatementCount" files="HandlerFactory\.java"/>

<suppress id="ImportControlTest" files="[\\/]powermock[\\/]" message=".* - org\.(powermock|mockito).*" />
</suppressions>