Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package net.fabricmc.loom.test

import java.lang.management.ManagementFactory

import org.gradle.util.GradleVersion

class LoomTestConstants {
Expand All @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -197,10 +196,6 @@ trait GradleProjectTestTrait {
writeBuildSrcDeps(runner)
}

if (options.disableDebugging) {
enableDebugging = false
}

return options.expectFailure ? runner.buildAndFail() : runner.build()
}

Expand All @@ -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() {
Expand Down