-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from hcoles/feature/pluggable_coverage
Pluggable coverage
- Loading branch information
Showing
8 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
pitest-entry/src/main/java/org/pitest/coverage/CompoundCoverageExporterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.pitest.coverage; | ||
|
||
import org.pitest.plugin.Feature; | ||
import org.pitest.plugin.FeatureSelector; | ||
import org.pitest.plugin.FeatureSetting; | ||
import org.pitest.util.ResultOutputStrategy; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class CompoundCoverageExporterFactory implements CoverageExporterFactory { | ||
|
||
private final FeatureSelector<CoverageExporterFactory> features; | ||
|
||
public CompoundCoverageExporterFactory(List<FeatureSetting> features, Collection<CoverageExporterFactory> children) { | ||
this.features = new FeatureSelector<>(features, children); | ||
} | ||
|
||
@Override | ||
public CoverageExporter create(ResultOutputStrategy source) { | ||
List<CoverageExporter> exporters = this.features.getActiveFeatures().stream() | ||
.map(f -> f.create(source)) | ||
.collect(Collectors.toList()); | ||
return c -> exporters.stream().forEach(exporter -> exporter.recordCoverage(c)); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Feature provides() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
pitest-entry/src/main/java/org/pitest/coverage/CoverageExporterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.pitest.coverage; | ||
|
||
import org.pitest.plugin.ProvidesFeature; | ||
import org.pitest.plugin.ToolClasspathPlugin; | ||
import org.pitest.util.ResultOutputStrategy; | ||
|
||
public interface CoverageExporterFactory extends ToolClasspathPlugin, ProvidesFeature { | ||
CoverageExporter create(ResultOutputStrategy source); | ||
} |
24 changes: 24 additions & 0 deletions
24
pitest-entry/src/main/java/org/pitest/coverage/DefaultCoverageExporterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.pitest.coverage; | ||
|
||
import org.pitest.coverage.export.DefaultCoverageExporter; | ||
import org.pitest.plugin.Feature; | ||
import org.pitest.util.ResultOutputStrategy; | ||
|
||
public class DefaultCoverageExporterFactory implements CoverageExporterFactory { | ||
@Override | ||
public CoverageExporter create(ResultOutputStrategy source) { | ||
return new DefaultCoverageExporter(source); | ||
} | ||
|
||
@Override | ||
public Feature provides() { | ||
return Feature.named("defaultCoverage") | ||
.withDescription(description()) | ||
.withOnByDefault(true); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Default coverage exporter"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...st-entry/src/main/resources/META-INF/services/org.pitest.coverage.CoverageExporterFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.pitest.coverage.DefaultCoverageExporterFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters