From 6e66a4706ecc9a55a4e1eab71de29e6851338101 Mon Sep 17 00:00:00 2001 From: Henry Coles Date: Fri, 21 Apr 2023 09:58:01 +0100 Subject: [PATCH] make test prioritised available to interceptors --- .../build/CompoundInterceptorFactory.java | 12 ++++++++---- .../mutationtest/build/InterceptorParameters.java | 9 ++++++++- .../mutationtest/tooling/MutationCoverage.java | 2 +- .../build/InterceptorParametersTest.java | 4 ++-- .../mutationtest/build/MutationDiscoveryTest.java | 2 +- .../verifier/interceptors/FactoryVerifier.java | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/pitest-entry/src/main/java/org/pitest/mutationtest/build/CompoundInterceptorFactory.java b/pitest-entry/src/main/java/org/pitest/mutationtest/build/CompoundInterceptorFactory.java index 9b6cb9477..cccc4d34a 100644 --- a/pitest-entry/src/main/java/org/pitest/mutationtest/build/CompoundInterceptorFactory.java +++ b/pitest-entry/src/main/java/org/pitest/mutationtest/build/CompoundInterceptorFactory.java @@ -23,9 +23,11 @@ public CompoundInterceptorFactory(List features, public CompoundMutationInterceptor createInterceptor( ReportOptions data, CoverageDatabase coverage, - ClassByteArraySource source) { + ClassByteArraySource source, + TestPrioritiser testPrioritiser + ) { final List 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); } @@ -35,9 +37,11 @@ private static Function toInter FeatureSelector 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)); } } \ No newline at end of file diff --git a/pitest-entry/src/main/java/org/pitest/mutationtest/build/InterceptorParameters.java b/pitest-entry/src/main/java/org/pitest/mutationtest/build/InterceptorParameters.java index 4d6648351..09a94fe0b 100644 --- a/pitest-entry/src/main/java/org/pitest/mutationtest/build/InterceptorParameters.java +++ b/pitest-entry/src/main/java/org/pitest/mutationtest/build/InterceptorParameters.java @@ -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() { @@ -43,6 +46,10 @@ public ClassByteArraySource source() { return this.source; } + public TestPrioritiser testPrioritiser() { + return this.testPrioritiser; + } + public Optional getString(FeatureParameter limit) { if (this.conf == null) { return Optional.empty(); diff --git a/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java b/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java index 814a14cc8..3257c2a93 100644 --- a/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java +++ b/pitest-entry/src/main/java/org/pitest/mutationtest/tooling/MutationCoverage.java @@ -362,7 +362,7 @@ private List 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); diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/InterceptorParametersTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/InterceptorParametersTest.java index 209d711c2..96a8179e6 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/InterceptorParametersTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/InterceptorParametersTest.java @@ -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()); } @@ -50,7 +50,7 @@ private InterceptorParameters makeFor(String key, String ... vals) { final Map> 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); } } diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationDiscoveryTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationDiscoveryTest.java index badb9b4af..1fda5c933 100755 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationDiscoveryTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/MutationDiscoveryTest.java @@ -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()) diff --git a/pitest-entry/src/test/java/org/pitest/verifier/interceptors/FactoryVerifier.java b/pitest-entry/src/test/java/org/pitest/verifier/interceptors/FactoryVerifier.java index 4e57eeb3d..ba7134a36 100644 --- a/pitest-entry/src/test/java/org/pitest/verifier/interceptors/FactoryVerifier.java +++ b/pitest-entry/src/test/java/org/pitest/verifier/interceptors/FactoryVerifier.java @@ -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() {