From 36cf73997f6a1362f97e3b0d12921bf58bf92e3d Mon Sep 17 00:00:00 2001 From: modmuss Date: Thu, 23 Oct 2025 19:25:17 +0100 Subject: [PATCH] Make the intergration tests easier to debug (#1401) * Make the intergration tests easier to debug * Spotless --- .../net/fabricmc/loom/test/LoomTestConstants.groovy | 5 +++++ .../loom/test/util/GradleProjectTestTrait.groovy | 12 +++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy index b7ec5d12..9759794c 100644 --- a/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/LoomTestConstants.groovy @@ -24,6 +24,8 @@ package net.fabricmc.loom.test +import java.lang.management.ManagementFactory + import org.gradle.util.GradleVersion class LoomTestConstants { @@ -46,6 +48,9 @@ class LoomTestConstants { public static final File TEST_DIR = new File("./.gradle/test-files") + // Try to detect if the debugging agent is enabled. + public static final boolean IS_DEBUGGING_ENABLED = ManagementFactory.runtimeMXBean.inputArguments.any { it.startsWith('-agentlib:jdwp') } + /** * Nightly gradle versions get removed after a certain amount of time, lets check to see if its still online before running the tests. */ diff --git a/src/test/groovy/net/fabricmc/loom/test/util/GradleProjectTestTrait.groovy b/src/test/groovy/net/fabricmc/loom/test/util/GradleProjectTestTrait.groovy index 86df3a47..06bf5ab6 100644 --- a/src/test/groovy/net/fabricmc/loom/test/util/GradleProjectTestTrait.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/util/GradleProjectTestTrait.groovy @@ -28,7 +28,6 @@ import groovy.transform.Immutable import org.apache.commons.io.FileUtils import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner -import org.gradle.util.GradleVersion import spock.lang.Shared import net.fabricmc.loom.test.LoomTestConstants @@ -149,7 +148,6 @@ trait GradleProjectTestTrait { private String gradleHomeDir private String warningMode private boolean useBuildSrc - private boolean enableDebugging = true BuildResult run(Map options) { // Setup the system props to tell loom that its running in a test env @@ -165,7 +163,8 @@ trait GradleProjectTestTrait { args << options.task } - boolean configurationCache = true + // Configuration cache is not compatible with the debugging agent. + boolean configurationCache = !LoomTestConstants.IS_DEBUGGING_ENABLED if (options.containsKey("configurationCache")) { configurationCache = options.configurationCache @@ -197,10 +196,6 @@ trait GradleProjectTestTrait { writeBuildSrcDeps(runner) } - if (options.disableDebugging) { - enableDebugging = false - } - return options.expectFailure ? runner.buildAndFail() : runner.build() } @@ -210,8 +205,7 @@ trait GradleProjectTestTrait { .withPluginClasspath() .withGradleVersion(gradleVersion) .forwardOutput() - // Only enable debugging when the current gradle version matches the version we are testing - .withDebug(enableDebugging && gradleVersion == GradleVersion.current().getVersion()) + .withDebug(LoomTestConstants.IS_DEBUGGING_ENABLED) } File getProjectDir() {