Skip to content

Commit

Permalink
Merge pull request #861 from hcoles/master
Browse files Browse the repository at this point in the history
Release 1.6.3
  • Loading branch information
hcoles authored Feb 16, 2021
2 parents 40c8526 + 6a4f021 commit 4238ce8
Show file tree
Hide file tree
Showing 63 changed files with 580 additions and 489 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Read all about it at http://pitest.org

## Releases

### 1.6.2

* #770 and #746 Fix NPE during coverage stage (thanks @LaurentTho3)
* #849 Make feature names case insensitive
* #844 Extend feature system to work with listeners
* #842 Make report options available to listeners

### 1.6.1

* Automate release to maven central
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/
package org.pitest.mutationtest.commandline;

import java.util.HashMap;

import org.pitest.coverage.CoverageSummary;
import org.pitest.mutationtest.config.PluginServices;
import org.pitest.mutationtest.config.ReportOptions;
Expand All @@ -25,6 +23,8 @@
import org.pitest.mutationtest.tooling.EntryPoint;
import org.pitest.util.Unchecked;

import java.util.HashMap;

/**
* Entry point for command line interface
*/
Expand All @@ -50,7 +50,7 @@ public static void main(final String[] args) {
data.getTestStrengthThreshold());
throwErrorIfScoreBelowMutationThreshold(stats.getMutationStatistics(),
data.getMutationThreshold());
throwErrorIfMoreThanMaxSuvivingMutants(stats.getMutationStatistics(), data.getMaximumAllowedSurvivors());
throwErrorIfMoreThanMaxSurvivingMutants(stats.getMutationStatistics(), data.getMaximumAllowedSurvivors());
}

}
Expand Down Expand Up @@ -81,9 +81,9 @@ private static void throwErrorIfScoreBelowTestStrengthThreshold(
}
}

private static void throwErrorIfMoreThanMaxSuvivingMutants(
private static void throwErrorIfMoreThanMaxSurvivingMutants(
final MutationStatistics stats, final long threshold) {
if ((threshold > 0)
if ((threshold >= 0)
&& (stats.getTotalSurvivingMutations() > threshold)) {
throw new RuntimeException("Had "
+ stats.getTotalSurvivingMutations() + " surviving mutants, but only "
Expand All @@ -96,7 +96,7 @@ private static CombinedStatistics runReport(ReportOptions data,

final EntryPoint e = new EntryPoint();
final AnalysisResult result = e.execute(null, data, plugins,
new HashMap<String, String>());
new HashMap<>());
if (result.getError().isPresent()) {
throw Unchecked.translateCheckedException(result.getError().get());
}
Expand Down
19 changes: 12 additions & 7 deletions pitest-entry/src/main/java/org/pitest/coverage/CoverageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

package org.pitest.coverage;

import static java.util.stream.Collectors.toCollection;
import org.pitest.classinfo.ClassInfo;
import org.pitest.classinfo.ClassName;
import org.pitest.classpath.CodeSource;
import org.pitest.functional.FCollection;
import org.pitest.testapi.Description;
import org.pitest.util.Log;

import java.math.BigInteger;
import java.util.ArrayList;
Expand All @@ -35,12 +40,7 @@
import java.util.logging.Logger;
import java.util.stream.Stream;

import org.pitest.classinfo.ClassInfo;
import org.pitest.classinfo.ClassName;
import org.pitest.classpath.CodeSource;
import org.pitest.functional.FCollection;
import org.pitest.testapi.Description;
import org.pitest.util.Log;
import static java.util.stream.Collectors.toCollection;

public class CoverageData implements CoverageDatabase {

Expand Down Expand Up @@ -185,6 +185,11 @@ public CoverageSummary createSummary() {
return new CoverageSummary(numberOfLines(), coveredLines());
}

@Override
public Map<InstructionLocation, Set<TestInfo>> getInstructionCoverage() {
return Collections.unmodifiableMap(this.instructionCoverage);
}

private BigInteger generateCoverageNumber(
final Map<ClassLine, Set<TestInfo>> coverage) {
BigInteger coverageNumber = BigInteger.ZERO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.pitest.coverage;

import java.math.BigInteger;
import java.util.Collection;

import org.pitest.classinfo.ClassInfo;
import org.pitest.classinfo.ClassName;

import java.math.BigInteger;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

public interface CoverageDatabase {

Collection<ClassInfo> getClassInfo(Collection<ClassName> classes);
Expand All @@ -24,4 +26,7 @@ public interface CoverageDatabase {

CoverageSummary createSummary();

Map<InstructionLocation, Set<TestInfo>> getInstructionCoverage();


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.pitest.mutationtest.build;

import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.coverage.CoverageDatabase;
import org.pitest.mutationtest.config.ReportOptions;
import org.pitest.plugin.FeatureSelector;
import org.pitest.plugin.FeatureSetting;
Expand All @@ -21,18 +22,22 @@ public CompoundInterceptorFactory(List<FeatureSetting> features,

public MutationInterceptor createInterceptor(
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {
final List<MutationInterceptor> interceptors = this.features.getActiveFeatures().stream()
.map(toInterceptor(this.features, data, source))
.map(toInterceptor(this.features, data, coverage, source))
.collect(Collectors.toList());
return new CompoundMutationInterceptor(interceptors);
}


private static Function<MutationInterceptorFactory, MutationInterceptor> toInterceptor(
final FeatureSelector<MutationInterceptorFactory> features, final ReportOptions data, final ClassByteArraySource source) {
FeatureSelector<MutationInterceptorFactory> features,
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {

return a -> a.createInterceptor(new InterceptorParameters(features.getSettingForFeature(a.provides().name()), data, source));
return a -> a.createInterceptor(new InterceptorParameters(features.getSettingForFeature(a.provides().name()), data, coverage, source));

}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
package org.pitest.mutationtest.build;

import java.util.Collections;
import java.util.List;

import org.pitest.classinfo.ClassByteArraySource;
import java.util.Optional;
import org.pitest.coverage.CoverageDatabase;
import org.pitest.mutationtest.config.ReportOptions;
import org.pitest.plugin.FeatureParameter;
import org.pitest.plugin.FeatureSetting;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

public final class InterceptorParameters {

private final FeatureSetting conf;
private final ReportOptions data;
private final ClassByteArraySource source;
private final CoverageDatabase coverage;


public InterceptorParameters(FeatureSetting conf, ReportOptions data,
public InterceptorParameters(FeatureSetting conf, ReportOptions data, CoverageDatabase coverage,
ClassByteArraySource source) {
this.conf = conf;
this.data = data;
this.coverage = coverage;
this.source = source;
}

public ReportOptions data() {
return this.data;
}

public CoverageDatabase coverage() {
return this.coverage;
}

public Optional<FeatureSetting> settings() {
return Optional.ofNullable(this.conf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Collection;
import java.util.function.Consumer;

import static org.pitest.functional.prelude.Prelude.printWith;
import static org.pitest.functional.prelude.Prelude.printlnWith;

public class WorkerFactory {

Expand Down Expand Up @@ -58,7 +58,7 @@ public MutationTestProcess createWorker(
final ProcessArgs args = ProcessArgs.withClassPath(this.classPath)
.andLaunchOptions(this.config.getLaunchOptions())
.andBaseDir(this.baseDir).andStdout(captureStdOutIfVerbose())
.andStderr(printWith("stderr "));
.andStderr(printlnWith("stderr "));

final SocketFinder sf = new SocketFinder();
return new MutationTestProcess(
Expand All @@ -67,7 +67,7 @@ public MutationTestProcess createWorker(

private Consumer<String> captureStdOutIfVerbose() {
if (this.verbose) {
return Prelude.printWith("stdout ");
return printlnWith("stdout ");
} else {
return Prelude.noSideEffect(String.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Collection<MutationDetails> intercept(
private Predicate<MutationDetails> mutatesIteratorLoopPlumbing() {
return a -> {
final int instruction = a.getInstructionIndex();
final MethodTree method = ForEachLoopFilter.this.currentClass.methods().stream()
final MethodTree method = currentClass.methods().stream()
.filter(MethodMatchers.forLocation(a.getId().getLocation()))
.findFirst()
.get();
Expand Down
Loading

0 comments on commit 4238ce8

Please sign in to comment.