Skip to content

Commit

Permalink
ensure mutation operator plugins added to client classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Sep 29, 2021
1 parent e4363a0 commit 38b0ea9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.pitest.mutationtest.build.MutationGrouperFactory;
import org.pitest.mutationtest.build.MutationInterceptorFactory;
import org.pitest.mutationtest.build.TestPrioritiserFactory;
import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory;
import org.pitest.plugin.ClientClasspathPlugin;
import org.pitest.plugin.ProvidesFeature;
import org.pitest.plugin.ToolClasspathPlugin;
Expand Down Expand Up @@ -48,13 +49,19 @@ public Collection<? extends ToolClasspathPlugin> findToolClasspathPlugins() {
* Lists all plugin classes that must be present on the classpath of the code
* under test at runtime
*/
public Iterable<? extends ClientClasspathPlugin> findClientClasspathPlugins() {
public List<? extends ClientClasspathPlugin> findClientClasspathPlugins() {
final List<ClientClasspathPlugin> l = new ArrayList<>();
l.addAll(findMutationEngines());
l.addAll(findMutationOperators());
l.addAll(findTestFrameworkPlugins());
l.addAll(nullPlugins());
return l;
}

public Collection<? extends MethodMutatorFactory> findMutationOperators() {
return ServiceLoader.load(MethodMutatorFactory.class, this.loader);
}

Collection<? extends TestPluginFactory> findTestFrameworkPlugins() {
return ServiceLoader.load(TestPluginFactory.class, this.loader);
}
Expand Down
17 changes: 11 additions & 6 deletions pitest-maven/src/main/java/org/pitest/maven/AbstractPitMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.pitest.coverage.CoverageSummary;
import org.pitest.mutationtest.config.PluginServices;
import org.pitest.mutationtest.config.ReportOptions;
import org.pitest.mutationtest.engine.gregor.MethodMutatorFactory;
import org.pitest.mutationtest.statistics.MutationStatistics;
import org.pitest.mutationtest.tooling.CombinedStatistics;
import org.pitest.plugin.ClientClasspathPlugin;
import org.pitest.plugin.ToolClasspathPlugin;
import org.slf4j.bridge.SLF4JBridgeHandler;
import uk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J;
Expand Down Expand Up @@ -405,11 +405,16 @@ public final void execute() throws MojoExecutionException,
this.getLog().info("Found plugin : " + each.description());
}

for (final ClientClasspathPlugin each : this.plugins
.findClientClasspathPlugins()) {
this.getLog().info(
"Found shared classpath plugin : " + each.description());
}
this.plugins.findClientClasspathPlugins().stream()
.filter(p -> !(p instanceof MethodMutatorFactory))
.forEach(p -> this.getLog().info(
"Found shared classpath plugin : " + p.description()));

String operators = this.plugins.findMutationOperators().stream()
.map(m -> m.getName())
.collect(Collectors.joining(","));

this.getLog().info("Available mutators : " + operators);

final Optional<CombinedStatistics> result = analyse();
if (result.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.pitest.mutationtest.engine.gregor;

import org.objectweb.asm.MethodVisitor;
import org.pitest.plugin.ClientClasspathPlugin;

/**
* A <code>MethodMutatorFactory</code> is a factory creating method mutating
Expand All @@ -32,7 +33,7 @@
*
* @author Henry Coles
*/
public interface MethodMutatorFactory {
public interface MethodMutatorFactory extends ClientClasspathPlugin {

MethodVisitor create(MutationContext context,
MethodInfo methodInfo, MethodVisitor methodVisitor);
Expand All @@ -55,4 +56,9 @@ MethodVisitor create(MutationContext context,
*/
String getName();

@Override
default String description() {
return getName();
}

}

0 comments on commit 38b0ea9

Please sign in to comment.