1212import org .pitest .mutationtest .config .ReportOptions ;
1313import org .pitest .mutationtest .config .Services ;
1414import org .pitest .mutationtest .config .ServicesFromClassLoader ;
15+ import org .pitest .mutationtest .engine .gregor .config .MutatorGroup ;
1516import org .pitest .mutationtest .tooling .AnalysisResult ;
1617import org .pitest .mutationtest .tooling .EntryPoint ;
1718import org .pitest .testapi .TestGroupConfig ;
@@ -93,7 +94,7 @@ public StageResult run(Submission submission) throws StageException {
9394 }
9495
9596
96- ReportOptions data = new ReportOptions ();
97+ ReportOptions data = new ReportIgnoringTests ();
9798 // Set the classes to mutate
9899 data .setTargetClasses (mutationTargets );
99100
@@ -126,14 +127,15 @@ public StageResult run(Submission submission) throws StageException {
126127 // Set source directories for report generation
127128 var sourceList = new ArrayList <Path >();
128129 sourceList .add (Path .of (submission .getSrcFolder ()));
129- sourceList .add (Path .of (submission .getTestFolder ()));
130+ // sourceList.add(Path.of(submission.getTestFolder()));
130131 data .setSourceDirs (sourceList );
131132
132133 // Set output directory
133134 data .setReportDir ("target/custom-pit-report" );
134135
135136 // Set mutators, threads, etc. (optional, defaults are often fine)
136- data .setMutators (Collections .singletonList ("DEFAULTS" ));
137+ //data.setMutators(Collections.singletonList("DEFAULTS"));
138+ data .setMutators (List .of ("INVERT_NEGS" , "MATH" , "VOID_METHOD_CALLS" , "REMOVE_CONDITIONALS" , "INCREMENTS" , "RETURNS" ));
137139
138140 data .setGroupConfig (new TestGroupConfig ());
139141 data .addOutputFormats (Collections .singletonList ("Chalkbox" ));
@@ -142,7 +144,9 @@ public StageResult run(Submission submission) throws StageException {
142144 data .setVerbosity (Verbosity .QUIET );
143145
144146 MutationListener listener = new MutationListener ();
145- PluginServices plugins = injectListener (listener );
147+ Map <Class <?>, Object > services = new HashMap <>();
148+ services .put (MutationResultListenerFactory .class , listener );
149+ PluginServices plugins = injectServices (services );
146150 AnalysisResult result ;
147151 try {
148152 var e = new EntryPoint ();
@@ -176,15 +180,17 @@ private StageResult failWithMessage(String cause) {
176180 );
177181 }
178182
179- private PluginServices injectListener ( MutationListener listener ) {
183+ private PluginServices injectServices ( Map < Class <?>, Object > services ) {
180184 Services fallback = new ServicesFromClassLoader (IsolationUtils .getContextClassLoader ());
181185 Services serviceLoader = new Services () {
182186 @ Override
183187 @ SuppressWarnings ("unchecked" ) // hopefully valid
184188 public <S > Collection <S > load (Class <S > ifc ) {
185189 // intercept lookup and include custom listener
186- if (ifc .isAssignableFrom (MutationResultListenerFactory .class )) {
187- return List .of ((S ) listener );
190+ for (Map .Entry <Class <?>, Object > entry : services .entrySet ()) {
191+ if (ifc .isAssignableFrom (entry .getKey ())) {
192+ return List .of ((S ) entry .getValue ());
193+ }
188194 }
189195 // fallback to default
190196 return fallback .load (ifc );
0 commit comments