Skip to content

Commit

Permalink
Issue #13672: Kill mutation in Common Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin222004 authored and romani committed Sep 30, 2023
1 parent afd0c2d commit 351bbc1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 45 deletions.
45 changes: 0 additions & 45 deletions config/pitest-suppressions/pitest-common-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,6 @@
<lineContent>final String stripped = CommonUtil.relativizeAndNormalizePath(basedir, fileName);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
<mutatedMethod>fireErrors</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CommonUtil::relativizeAndNormalizePath with argument</description>
<lineContent>final String stripped = CommonUtil.relativizeAndNormalizePath(basedir, fileName);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
<mutatedMethod>fireFileFinished</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CommonUtil::relativizeAndNormalizePath with argument</description>
<lineContent>final String stripped = CommonUtil.relativizeAndNormalizePath(basedir, fileName);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
<mutatedMethod>fireFileStarted</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
<description>replaced call to com/puppycrawl/tools/checkstyle/utils/CommonUtil::relativizeAndNormalizePath with argument</description>
<lineContent>final String stripped = CommonUtil.relativizeAndNormalizePath(basedir, fileName);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
Expand Down Expand Up @@ -99,15 +72,6 @@
<lineContent>throw new Error(&quot;Error was thrown while processing &quot; + file.getPath(), error);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
<mutatedMethod>setCharset</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable charset</description>
<lineContent>this.charset = charset;</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
Expand Down Expand Up @@ -162,15 +126,6 @@
<lineContent>final String value = attributes.getValue(VALUE);</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>ConfigurationLoader.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.ConfigurationLoader$InternalLoader</mutatedClass>
<mutatedMethod>startElement</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
<description>removed call to org/xml/sax/Attributes::getValue</description>
<lineContent>overridePropsResolver, attributes.getValue(DEFAULT));</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>LocalizedMessage.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.LocalizedMessage</mutatedClass>
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4357,12 +4357,15 @@
<param>com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParseTreeTest</param>
<!-- this test is required for Checker -->
<param>com.puppycrawl.tools.checkstyle.filefilters.BeforeExecutionExclusionFileFilterTest</param>
<param>com.puppycrawl.tools.checkstyle.checks.TranslationCheckTest</param>
<!-- This test is the primary user of metadataGeneratorLogger -->
<param>com.puppycrawl.tools.checkstyle.meta.MetadataGeneratorUtilTest</param>
<!-- kills mutation in AbstractAutomaticBean -->
<param>com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheckTest</param>
<!-- kills mutation in AbstractAutomaticBean -->
<param>com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest</param>
<!-- kills mutation in ConfigurationLoader -->
<param>com.sun.checkstyle.test.chapter5comments.rule52documentationcomments.InvalidJavadocPositionTest</param>
</targetTests>
<excludedMethods>
<!-- caching of search results, big performance optimization -->
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static com.puppycrawl.tools.checkstyle.DefaultLogger.AUDIT_FINISHED_MESSAGE;
import static com.puppycrawl.tools.checkstyle.DefaultLogger.AUDIT_STARTED_MESSAGE;
import static com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck.MSG_KEY_NO_NEWLINE_EOF;
import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -74,6 +75,7 @@
import com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck;
import com.puppycrawl.tools.checkstyle.checks.TranslationCheck;
import com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck;
import com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck;
import com.puppycrawl.tools.checkstyle.filters.SuppressionFilter;
import com.puppycrawl.tools.checkstyle.internal.testmodules.DebugAuditAdapter;
import com.puppycrawl.tools.checkstyle.internal.testmodules.DebugFilter;
Expand All @@ -82,6 +84,7 @@
import com.puppycrawl.tools.checkstyle.internal.utils.CloseAndFlushTestByteArrayOutputStream;
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
import de.thetaphi.forbiddenapis.SuppressForbidden;

/**
* CheckerTest.
Expand Down Expand Up @@ -1665,6 +1668,22 @@ public void testCachedFile() throws Exception {
checker.destroy();
}

@SuppressForbidden
@Test
public void testUnmappableCharacters() throws Exception {
final String[] expected = {
"4: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 238),
};

final DefaultConfiguration checkConfig = createModuleConfig(LineLengthCheck.class);
checkConfig.addProperty("max", "75");

final DefaultConfiguration checkerConfig = createRootConfig(checkConfig);
checkerConfig.addProperty("charset", "IBM1098");

verify(checkerConfig, getPath("InputCheckerTestCharset.java"), expected);
}

public static class DefaultLoggerWithCounter extends DefaultLogger {

private int fileStartedCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.puppycrawl.tools.checkstyle.checker;

public class InputCheckerTestCharset {
String a = "ᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀᾀ"; // violation
}

0 comments on commit 351bbc1

Please sign in to comment.