Skip to content

Commit

Permalink
Merge pull request #1190 from hcoles/feature/early_coverage_assignment
Browse files Browse the repository at this point in the history
make test prioritiser available to interceptors
  • Loading branch information
hcoles authored Apr 21, 2023
2 parents 7d5e20a + 6e66a47 commit e429fb9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public CompoundInterceptorFactory(List<FeatureSetting> features,
public CompoundMutationInterceptor createInterceptor(
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {
ClassByteArraySource source,
TestPrioritiser testPrioritiser
) {
final List<MutationInterceptor> interceptors = this.features.getActiveFeatures().stream()
.map(toInterceptor(this.features, data, coverage, source))
.map(toInterceptor(this.features, data, coverage, source, testPrioritiser))
.collect(Collectors.toList());
return new CompoundMutationInterceptor(interceptors);
}
Expand All @@ -35,9 +37,11 @@ private static Function<MutationInterceptorFactory, MutationInterceptor> toInter
FeatureSelector<MutationInterceptorFactory> features,
ReportOptions data,
CoverageDatabase coverage,
ClassByteArraySource source) {
ClassByteArraySource source,
TestPrioritiser testPrioritiser
) {

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

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ public final class InterceptorParameters {
private final ClassByteArraySource source;
private final CoverageDatabase coverage;

private final TestPrioritiser testPrioritiser;


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

public ReportOptions data() {
Expand All @@ -43,6 +46,10 @@ public ClassByteArraySource source() {
return this.source;
}

public TestPrioritiser testPrioritiser() {
return this.testPrioritiser;
}

public Optional<String> getString(FeatureParameter limit) {
if (this.conf == null) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ private List<MutationAnalysisUnit> buildMutationTests(CoverageDatabase coverageD
coverageData);

final MutationInterceptor interceptor = this.settings.getInterceptor()
.createInterceptor(this.data, coverageData, bas)
.createInterceptor(this.data, coverageData, bas, testPrioritiser)
.filter(interceptorFilter);

interceptor.initialise(this.code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void shouldReturnNoneWhenValueAbsent() {

@Test
public void shouldReturnNoneWhenFeatureSettingsAbsent() {
this.testee = new InterceptorParameters(null, null, null, null);
this.testee = new InterceptorParameters(null, null, null, null, null);
assertThat(this.testee.getString(FeatureParameter.named("foo"))).isEqualTo(Optional.empty());
}

Expand All @@ -50,7 +50,7 @@ private InterceptorParameters makeFor(String key, String ... vals) {
final Map<String, List<String>> values = new HashMap<>();
values.put(key, Arrays.asList(vals));
final FeatureSetting fs = new FeatureSetting(null, null, values);
return new InterceptorParameters(fs, null, null,null);
return new InterceptorParameters(fs, null, null,null, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ MutationSource createSource(ClassByteArraySource source) {
final SettingsFactory settings = new SettingsFactory(this.data,
PluginServices.makeForContextLoader());
final MutationInterceptor interceptor = settings.getInterceptor()
.createInterceptor(this.data, null, source);
.createInterceptor(this.data, null, source, null);

final MutationEngine engine = new GregorEngineFactory().createEngine(
EngineArguments.arguments().withExcludedMethods(this.data.getExcludedMethods())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static void factoryIsOnChain(Class<?> factory) {
}

public static InterceptorParameters emptyParams(ReportOptions data) {
return new InterceptorParameters(null, data, null, null);
return new InterceptorParameters(null, data, null, null, null);
}

public static ReportOptions emptyOptions() {
Expand Down

0 comments on commit e429fb9

Please sign in to comment.