Issue #13109: Kill mutation for PackageDeclarationCheck#13133
Issue #13109: Kill mutation for PackageDeclarationCheck#13133romani merged 1 commit intocheckstyle:masterfrom
Conversation
|
why draft ? no regression report is executed. we already discussed somewhere that all reset in beginTree are for case when same instance of Check is used on two files, Check is state-ful, and we should not affect new files by values in fields from previous java file. |
|
How long it takes for your local to generate such report ? Link in report is not working https://kevin222004.github.io/reports/p1/2023-06-02-T-08-07-37/test-report/dbeaver/xref/__w/Kevin222004.github.io/Kevin222004.github.io/contribution/checkstyle-tester/repositories/dbeaver/plugins/org.jkiss.dbeaver.ext.mysql/src/MySQLErrorsTest.java.html#L18 |
|
@romani i am not generating report on local but ci takes almost or more than 3 hours for one single report, so mostly my local will crash if I generate on it :)
yes i have to look why it is not working |
|
|
||
| @Override | ||
| public void beginTree(DetailAST ast) { | ||
| defined = false; |
There was a problem hiding this comment.
reminder, all initialization in this method, is reset of Check state before starting new file, to reproduce problem we need to run same Check instance on 2 special input files to let "defined = true" affect validation in second file even it has no java code that make "defined = true".
There was a problem hiding this comment.
@romani I have tried to write a test case as in other check.
@Test
public void testClearStateInLambda() throws Exception {
final PackageDeclarationCheck check = new PackageDeclarationCheck();
final Optional<DetailAST> package_def = TestUtil.findTokenInAstByPredicate(
JavaParser.parseFile(
new File(getPath("InputPackageDeclarationPlain.java")),
JavaParser.Options.WITHOUT_COMMENTS),
ast -> ast.getType() == TokenTypes.PACKAGE_DEF);
assertWithMessage("ast should contain PACKAGE_DEF")
.that(package_def.isPresent())
.isTrue();
assertWithMessage("State is not cleared on beginTree")
.that(TestUtil.isStatefulFieldClearedDuringBeginTree(check, package_def.get(),
"defined", defined -> {
return !((boolean) defined);
}))
.isTrue();
}
I am getting only null pointer exception here am i missing any thing.
java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.FileContents.getFileName()" because "java.lang.ThreadLocal.get().fileContents" is null
at com.puppycrawl.tools.checkstyle.api.AbstractCheck.getFilePath(AbstractCheck.java:317)
at com.puppycrawl.tools.checkstyle.checks.coding.PackageDeclarationCheck.getDirectoryName(PackageDeclarationCheck.java:183)
at com.puppycrawl.tools.checkstyle.checks.coding.PackageDeclarationCheck.visitToken(PackageDeclarationCheck.java:169)
at com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isStatefulFieldClearedDuringBeginTree(TestUtil.java:139)
There was a problem hiding this comment.
Do not deal with pure Junit method , we should cover it by Inputs.
New or existing verify method that takes creates check ones and execute two files sequentially.
abbc72b to
3c3a6f1
Compare
romani
left a comment
There was a problem hiding this comment.
Ok to merge.
Just Input based test extension, best scenario.
I move it further for review by others to learn on this.
| @@ -0,0 +1,7 @@ | |||
| package com.puppycrawl.tools.checkstyle.checks.coding.packagedeclaration; | |||
There was a problem hiding this comment.
So, why do we need this new input file if it is not used in the new test?
Issue #13109: Kill mutation for PackageDeclarationCheck
Mutation
checkstyle/config/pitest-suppressions/pitest-coding-1-suppressions.xml
Lines 48 to 55 in 81448ea