From 2084ae1d1f71363517e5cd8871d87e90ce1557f6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 13 Jun 2023 21:04:07 +0100 Subject: [PATCH] Make predictive test selection opt-in Closes gh-35869 --- .../springframework/boot/build/JavaConventions.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java index 52c396c9f91..ae7dc0b2600 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java @@ -70,7 +70,8 @@ import org.springframework.util.StringUtils; *
  • with a max heap of 1024M *
  • to run after any Checkstyle and format checking tasks *
  • to enable retries with a maximum of three attempts when running on CI - *
  • to use predictive test selection when running locally + *
  • to use predictive test selection when the value of the + * {@code ENABLE_PREDICTIVE_TEST_SELECTION} environment variable is {@code true} * *
  • A {@code testRuntimeOnly} dependency upon * {@code org.junit.platform:junit-platform-launcher} is added to projects with the @@ -181,8 +182,12 @@ class JavaConventions { testRetry.getMaxRetries().set(isCi() ? 3 : 0); } + private boolean isCi() { + return Boolean.parseBoolean(System.getenv("CI")); + } + private void configurePredictiveTestSelection(Test test) { - if (!isCi()) { + if (isPredictiveTestSelectionEnabled()) { PredictiveTestSelectionExtension predictiveTestSelection = test.getExtensions() .getByType(PredictiveTestSelectionExtension.class); predictiveTestSelection.getEnabled().set(true); @@ -191,8 +196,8 @@ class JavaConventions { } } - private boolean isCi() { - return Boolean.parseBoolean(System.getenv("CI")); + private boolean isPredictiveTestSelectionEnabled() { + return Boolean.parseBoolean(System.getenv("ENABLE_PREDICTIVE_TEST_SELECTION")); } private void configureJavadocConventions(Project project) {