minor: Kill Mutation for AbstractHeaderCheck#13268
minor: Kill Mutation for AbstractHeaderCheck#13268Kevin222004 wants to merge 1 commit intocheckstyle:masterfrom
Conversation
| checker.setCharset("US-ASCII"); | ||
| final String[] expected = { | ||
| "1: " + getCheckMessage(MSG_HEADER_MISMATCH, "// some.class.тест.passed"), | ||
| }; |
There was a problem hiding this comment.
@romani in the same file I have created 2 test cases with name testCharsetProperty and testCharsetProperty2
To show that the setter in AbstractHeaderCheck is useless.
In first test case testCharsetProperty I have set the property charset in the parent module checker.
hence you can observe the violation
"1: " + getCheckMessage(MSG_HEADER_MISMATCH, "// some.class.тест.passed"),
and in second Test case testCharsetProperty2 where property is setted in check it self
and the message we got
"1: " + getCheckMessage(MSG_HEADER_MISMATCH, "// some.class.��������.passed"),
so I feel that we are not setting any property in check it is been setting up in checker only.
In the main pr at #13269
you can see I have removed that.
There was a problem hiding this comment.
I am not sure about this that why this is happening, I have currently removed the setter from the main pr.
There was a problem hiding this comment.
please create same testing by CLI, to make sure we do all as users and system works as expected.
in junit we always need to be accurate as we might miss some actions that actual system is doing.
We did propogation of such properties to all children modules.
There was a problem hiding this comment.
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat config.header
// some.class.тест.passed
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat header.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="US-ASCII" />
<module name="RegexpHeader">
<property name="headerFile" value="config.header"/>
</module>
</module>
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat Test2.java
// some.class
public class Test2 {
}
kevin@inspiron-15-5510:~/Desktop/check_style/header$
kevin@inspiron-15-5510:~/Desktop/check_style/header$ java -jar /home/kevin/Downloads/checkstyle-10.12.1-all.jar -c header.xml Test2.java
Starting audit...
[ERROR] /home/kevin/Desktop/check_style/header/Test2.java:1: Line does not match expected header line of '// some.class.��������.passed'. [RegexpHeader]
Audit done.
Checkstyle ends with 1 errors.
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat config.header
// some.class.тест.passed
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat Test2.java
// some.class
public class Test2 {
}
kevin@inspiron-15-5510:~/Desktop/check_style/header$ cat header2.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- <property name="charset" value="US-ASCII" /> -->
<module name="RegexpHeader">
<property name="charset" value="US-ASCII" />
<property name="headerFile" value="config.header"/>
</module>
</module>
kevin@inspiron-15-5510:~/Desktop/check_style/header$ java -jar /home/kevin/Downloads/checkstyle-10.12.1-all.jar -c header2.xml Test2.java
Starting audit...
[ERROR] /home/kevin/Desktop/check_style/header/Test2.java:1: Line does not match expected header line of '// some.class.��������.passed'. [RegexpHeader]
Audit done.
Checkstyle ends with 1 errors.
kevin@inspiron-15-5510:~/Desktop/check_style/header$
There was a problem hiding this comment.
@romani looks like with cli non of them is working
There was a problem hiding this comment.
If we drop non ASCII symbols, expected match is // some.class..passed
Please create Input based test method to see what is actual string for match.
There was a problem hiding this comment.
@romani I have some misconceptions on this pr.
There was a problem hiding this comment.
@Kevin222004 , please update this PR to have mutation removal, I lost a point of this PR.
|
I have updated the pr and updated the test as well and they are working as expected. Just for mutation purpose the mutation on setCharset is killed checkstyle/config/pitest-suppressions/pitest-header-suppressions.xml Lines 39 to 46 in 0827624 But still I believe that, the actuall testing of this property is been done when the issue #13392 |
|
Rest all the mutations are on the line In my opinion this is by default Also suggested at #13269 (comment) |
|
I confirm that and populated further to all modules by context: checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/Checker.java Lines 448 to 455 in 0827624 so after module instantiation, this Check use charset from its itialization, but it instantly changed by setter to what ever is Checker/context. here is stacktrace (I just executed HeaderCheckTest.testInvalidCharset): setCharset is required, but initialzation in class field is not. |

minor: Kill Mutation for AbstractHeaderCheck
for #13269