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 #4394: increase coverage of pitest-checkstyle-api profile to 96% #4704

Merged
merged 1 commit into from Jul 14, 2017

Conversation

Nimfadora
Copy link
Contributor

Issue #4394

pitest-checkstyle-api profile before changes

increased mutation threshold for pitest-checkstyle-api-filters profile by 8%
current threshold: 96%
execution time: 9:51 min

@@ -227,11 +227,12 @@ public int getLineNo() {
// with initialize(String text)
resultNo = findLineNo(getFirstChild());

if (resultNo < 0) {
//line number cannot be less than 1
if (resultNo == -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we add comment here but no where else in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just forgot to remove this one.

Copy link
Member

Choose a reason for hiding this comment

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

Then please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -49,12 +49,6 @@
*/
public abstract class AbstractLoader
extends DefaultHandler {
/** Feature that enables loading external DTD when loading XML files. */
private static final String LOAD_EXTERNAL_DTD =
"http://apache.org/xml/features/nonvalidating/load-external-dtd";
Copy link
Member

Choose a reason for hiding this comment

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

@romani Please review these removals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those features are enabled by default. I moved them to the tests - to always be sure that they are still enabled.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@Nimfadora ,
Unfortunately, this is weird feature request from googlers , please see commit and related issue #3605 .
How can we suppress pitest there or any other workaround (I am ok to move that code to special method addFeauresForVerySecureJavaInstallations and suppress pitest on this method)?

Copy link
Contributor Author

@Nimfadora Nimfadora Jul 12, 2017

Choose a reason for hiding this comment

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

@romani it's kinda troublesome. I can exclude addFeauresForVerySecureJavaInstallations from being mutated, but I cannot suppress mutation of the call to this method. avoidCallTo in PIT config didn't help, cause it allows only class names as params.
I can pull this method to the separate class, eg AbstractLoaderUtils, and this helps. Is it fine or an overkill?

Copy link
Member

Choose a reason for hiding this comment

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

please try to do this by means of inner class in AbstractLoader, if it does not help ... ok to make separate top level class FeauresForVerySecureJavaInstallations in javadoc make it clear that it is result of conflict of pitest and user requirements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

check.log(0, "key", "args");
final Collection<LocalizedMessage> messages =
(Collection<LocalizedMessage>) Whitebox.getInternalState(check, "messages");
check.clearMessages();
Copy link
Member

Choose a reason for hiding this comment

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

Can we add an assertion right before this that messages' size isn't 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

final BitSet branchTokenTypes = Whitebox.invokeMethod(parent, "getBranchTokenTypes");
method.accept(null);
final BitSet branchTokenTypes2 = Whitebox.invokeMethod(parent, "getBranchTokenTypes");
assertNotSame(branchTokenTypes, branchTokenTypes2);
Copy link
Member

Choose a reason for hiding this comment

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

We can't do more than notSame? It makes this a vague test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really sure how. BitSets actually are equals each time. By this test, I wanted to ensure that each call to add/set sibling/child methods force bitset to be recalculated.

Copy link
Member

Choose a reason for hiding this comment

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

Can we then assert the resulting values are the same?
NotSame atleast verifies instance is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

testNonValidCoordinates(0, 0, "MyTest.MyTestik[15x14]");
}

private static void testNonValidCoordinates(int columnNo, int lineNo, String expected) {
Copy link
Member

Choose a reason for hiding this comment

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

Non-test methods shouldn't start with test. Rename test to validate.
Also romani doesn't like assertions outside of test method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

items to improve:

@@ -49,12 +49,6 @@
*/
public abstract class AbstractLoader
extends DefaultHandler {
/** Feature that enables loading external DTD when loading XML files. */
private static final String LOAD_EXTERNAL_DTD =
"http://apache.org/xml/features/nonvalidating/load-external-dtd";
Copy link
Member

Choose a reason for hiding this comment

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

@Nimfadora ,
Unfortunately, this is weird feature request from googlers , please see commit and related issue #3605 .
How can we suppress pitest there or any other workaround (I am ok to move that code to special method addFeauresForVerySecureJavaInstallations and suppress pitest on this method)?

@Nimfadora
Copy link
Contributor Author

Build failed with
[testClass=com.puppycrawl.tools.checkstyle.api.FileTextTest, name=testLineColumnAfterCopyConstructor(com.puppycrawl.tools.checkstyle.api.FileTextTest)] did not pass without mutation.
This test definitly passes localy. What have I done wrong?

@rnveach
Copy link
Member

rnveach commented Jul 12, 2017

This test definitly passes localy. What have I done wrong?

First thing that comes to mind is make sure you are up to date with master.
I cannot look into it right now.

@romani
Copy link
Member

romani commented Jul 12, 2017

@Nimfadora , on my local for your branch the same on Travis:

$ mvn test
......
[ERROR] Failures: 
[ERROR]   FileTextTest.testLineColumnAfterCopyConstructor:92 expected:<44> but was:<46>

please recheck that tests are passing before pitest execution as it heavily affect pitest.

@codecov-io
Copy link

codecov-io commented Jul 14, 2017

Codecov Report

Merging #4704 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #4704   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         287     287           
  Lines       15386   15388    +2     
  Branches     3501    3501           
======================================
+ Hits        15386   15388    +2
Impacted Files Coverage Δ
...com/puppycrawl/tools/checkstyle/api/DetailAST.java 100% <100%> (ø) ⬆️
.../com/puppycrawl/tools/checkstyle/api/FileText.java 100% <100%> (ø) ⬆️
...ools/checkstyle/api/AbstractViolationReporter.java 100% <100%> (ø) ⬆️
...uppycrawl/tools/checkstyle/api/AbstractLoader.java 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66d866e...89c779c. Read the comment docs.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

as Shippable pas , we could merge

@romani romani merged commit 94df4ad into checkstyle:master Jul 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants