Skip to content

Commit

Permalink
Merge pull request #933 from hcoles/cleanup_plugin_param
Browse files Browse the repository at this point in the history
remove dead test plugin code
  • Loading branch information
hcoles authored Sep 16, 2021
2 parents a2531a0 + 1992d87 commit 3687124
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ public ParseResult parse(final String[] args) {
*/
private ParseResult parseCommandLine(final ReportOptions data,
final OptionSet userArgs) {
data.setTestPlugin(userArgs.valueOf(this.testPluginSpec));
data.setReportDir(userArgs.valueOf(this.reportDirSpec));
data.setTargetClasses(this.targetClassesSpec.values(userArgs));
data.setTargetTests(FCollection.map(this.targetTestsSpec.values(userArgs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.pitest.mutationtest.commandline;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -64,8 +65,8 @@ public void setUp() {
@Test
public void shouldParseTestPlugin() {
final String value = "foo";
final ReportOptions actual = parseAddingRequiredArgs("--testPlugin", value);
assertEquals(value, actual.getTestPlugin());
assertThatCode(() -> parseAddingRequiredArgs("--testPlugin", value))
.doesNotThrowAnyException();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,18 +602,10 @@ public void setIncludedTestMethods(Collection<String> includedTestMethods) {
* Creates a serializable subset of data for use in child processes
*/
public TestPluginArguments createMinionSettings() {
return new TestPluginArguments(getTestPlugin(), this.getGroupConfig(), this.getExcludedRunners(),
return new TestPluginArguments(this.getGroupConfig(), this.getExcludedRunners(),
this.getIncludedTestMethods(), this.skipFailingTests());
}

public String getTestPlugin() {
return this.testPlugin;
}

public void setTestPlugin(String testPlugin) {
this.testPlugin = testPlugin;
}

public boolean useClasspathJar() {
return useClasspathJar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public AnalysisResult execute(File baseDir, ReportOptions data,

checkMatrixMode(data);

selectTestPlugin(data);

final ClassPath cp = data.getClassPath();

// workaround for apparent java 1.5 JVM bug . . . might not play nicely
Expand Down Expand Up @@ -145,25 +143,6 @@ private void checkMatrixMode(ReportOptions data) {
}
}

private void selectTestPlugin(ReportOptions data) {
if ((data.getTestPlugin() == null) || data.getTestPlugin().equals("")) {
if (junit5PluginIsOnClasspath()) {
data.setTestPlugin("junit5");
} else {
data.setTestPlugin("junit");
}
}
}

private boolean junit5PluginIsOnClasspath() {
try {
Class.forName("org.pitest.junit5.JUnit5TestPluginFactory");
return true;
} catch (final ClassNotFoundException e) {
return false;
}
}

private Consumer<Feature> asInfo(final String leader) {
return a -> {
Log.getLogger().info(String.format("%1$-16s",leader + a.name()) + a.description());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public class MutationCoverageReportSystemTest extends ReportTestBase {
@Before
public void excludeTests() {
this.data.setExcludedClasses(asList("*Test"));
this.data.setTestPlugin("junit");
}

@Test
Expand Down Expand Up @@ -268,7 +267,6 @@ public void shouldSupportTestNG() {
this.data
.setTargetClasses(asList("com.example.testng.FullyCovered*"));
this.data.setVerbose(true);
this.data.setTestPlugin("testng");
createAndRun();
verifyResults(KILLED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void setUp() {
this.data = new ReportOptions();
this.data.setSourceDirs(Collections.<File> emptyList());
this.data.setGroupConfig(new TestGroupConfig());
this.data.setTestPlugin("junit");
}

protected MutationResultListenerFactory listenerFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ private ReportOptions parseReportOptions(final List<String> classPath) {
}

data.setUseClasspathJar(this.mojo.isUseClasspathJar());
data.setTestPlugin(this.mojo.getTestPlugin());
data.setClassPathElements(classPath);
data.setDependencyAnalysisMaxDistance(this.mojo.getMaxDependencyDistance());
data.setFailWhenNoMutations(shouldFailWhenNoMutations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,8 @@ public void testParsesCustomProperties() {
assertEquals("bar", actual.getFreeFormProperties().get("bar"));
}

public void testParsesTestPlugin() {
final ReportOptions actual = parseConfig("<testPlugin>testng</testPlugin>");
assertEquals("testng", actual.getTestPlugin());
public void testDoesNotErrorIfDefunctTestPluginArgumentSupplied() {
parseConfig("<testPlugin>testng</testPlugin>");
}

public void testDoesNotUseClasspathJarByDefault() {
Expand Down
2 changes: 1 addition & 1 deletion pitest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<jdk>17</jdk>
</activation>
<properties>
<!-- pitest does not use reflection, but some of the tests depend on xstream, which does. Jdk 16 fails with
<!-- pitest does not use reflection, but some of the tests depend on xstream, which does. Jdk 17 fails with
errors due to the module system. jdk8 does not support the add-opens option, so it must be activated here by jdk-->
<surefire.argline>--illegal-access=permit --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.ref=ALL-UNNAMED</surefire.argline>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,36 @@
import java.util.Collections;
import java.util.Objects;

import org.pitest.junit.JUnitTestPlugin;
import org.pitest.testapi.TestGroupConfig;

public class TestPluginArguments implements Serializable {

private static final long serialVersionUID = 1L;

private final String testPlugin;
private final TestGroupConfig groupConfig;
private final Collection<String> includedTestMethods;
private final Collection<String> excludedRunners;
private final boolean skipFailingTests;

public TestPluginArguments(String testPlugin,
TestGroupConfig groupConfig,
public TestPluginArguments(TestGroupConfig groupConfig,
Collection<String> excludedRunners,
Collection<String> includedTestMethods,
boolean skipFailingTests) {
Objects.requireNonNull(testPlugin);
Objects.requireNonNull(groupConfig);
Objects.requireNonNull(excludedRunners);
this.testPlugin = testPlugin;
this.groupConfig = groupConfig;
this.excludedRunners = excludedRunners;
this.includedTestMethods = includedTestMethods;
this.skipFailingTests = skipFailingTests;
}

public static TestPluginArguments defaults() {
return new TestPluginArguments(JUnitTestPlugin.NAME, new TestGroupConfig(), Collections.emptyList(),
return new TestPluginArguments(new TestGroupConfig(), Collections.emptyList(),
Collections.emptyList(), false);
}

public TestPluginArguments withTestPlugin(String plugin) {
return new TestPluginArguments(plugin, this.groupConfig, this.excludedRunners, this.includedTestMethods, this.skipFailingTests);
return new TestPluginArguments(this.groupConfig, this.excludedRunners, this.includedTestMethods, this.skipFailingTests);
}

public TestGroupConfig getGroupConfig() {
Expand All @@ -54,10 +49,6 @@ public Collection<String> getIncludedTestMethods() {
return this.includedTestMethods;
}

public String getTestPlugin() {
return this.testPlugin;
}

public boolean skipFailingTests() {
return this.skipFailingTests;
}
Expand Down

0 comments on commit 3687124

Please sign in to comment.