From 7f6598dc970d167e94a4fcb57086e975eaf5df90 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Mon, 15 Jun 2020 11:50:39 +0200 Subject: [PATCH] Make Gradle IT tests debuggable (#58093) - This configures the testkit gradle runner to run with debug enabled automatically when test is executed in debug mode (e.g. from the IDE) - Allows step by step debugging of GradleIntegrationTestCase tests --- .../gradle/test/GradleIntegrationTestCase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java b/buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java index 0b57e65388049..5a04f3e85cb3a 100644 --- a/buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java +++ b/buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java @@ -10,6 +10,7 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; +import java.lang.management.ManagementFactory; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -43,7 +44,11 @@ protected GradleRunner getGradleRunner(String sampleProject) { } catch (IOException e) { throw new UncheckedIOException(e); } - return GradleRunner.create().withProjectDir(getProjectDir(sampleProject)).withPluginClasspath().withTestKitDir(testkit); + return GradleRunner.create() + .withProjectDir(getProjectDir(sampleProject)) + .withPluginClasspath() + .withTestKitDir(testkit) + .withDebug(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0); } protected File getBuildDir(String name) {