Skip to content

Commit 2084ae1

Browse files
committed
Make predictive test selection opt-in
Closes gh-35869
1 parent b2ef9da commit 2084ae1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
* <li>with a max heap of 1024M
7171
* <li>to run after any Checkstyle and format checking tasks
7272
* <li>to enable retries with a maximum of three attempts when running on CI
73-
* <li>to use predictive test selection when running locally
73+
* <li>to use predictive test selection when the value of the
74+
* {@code ENABLE_PREDICTIVE_TEST_SELECTION} environment variable is {@code true}
7475
* </ul>
7576
* <li>A {@code testRuntimeOnly} dependency upon
7677
* {@code org.junit.platform:junit-platform-launcher} is added to projects with the
@@ -181,8 +182,12 @@ private void configureTestRetries(Test test) {
181182
testRetry.getMaxRetries().set(isCi() ? 3 : 0);
182183
}
183184

185+
private boolean isCi() {
186+
return Boolean.parseBoolean(System.getenv("CI"));
187+
}
188+
184189
private void configurePredictiveTestSelection(Test test) {
185-
if (!isCi()) {
190+
if (isPredictiveTestSelectionEnabled()) {
186191
PredictiveTestSelectionExtension predictiveTestSelection = test.getExtensions()
187192
.getByType(PredictiveTestSelectionExtension.class);
188193
predictiveTestSelection.getEnabled().set(true);
@@ -191,8 +196,8 @@ private void configurePredictiveTestSelection(Test test) {
191196
}
192197
}
193198

194-
private boolean isCi() {
195-
return Boolean.parseBoolean(System.getenv("CI"));
199+
private boolean isPredictiveTestSelectionEnabled() {
200+
return Boolean.parseBoolean(System.getenv("ENABLE_PREDICTIVE_TEST_SELECTION"));
196201
}
197202

198203
private void configureJavadocConventions(Project project) {

0 commit comments

Comments
 (0)