diff --git a/.gitlab/collect_results.sh b/.gitlab/collect_results.sh index 1d5027bc811..5991a125902 100755 --- a/.gitlab/collect_results.sh +++ b/.gitlab/collect_results.sh @@ -12,7 +12,13 @@ WORKSPACE_DIR=workspace mkdir -p $TEST_RESULTS_DIR mkdir -p $WORKSPACE_DIR -mapfile -t TEST_RESULT_DIRS < <(find $WORKSPACE_DIR -name test-results -type d) +# Main project modules redirect their build directory to workspace//build/ in CI +# (see build.gradle.kts layout.buildDirectory override). buildSrc is a separate Gradle build +# that runs before the main build is configured, so this redirect never applies to it; +# its test results always land in buildSrc/**/build/test-results/, not under workspace/. +SEARCH_DIRS=($WORKSPACE_DIR buildSrc) + +mapfile -t TEST_RESULT_DIRS < <(find "${SEARCH_DIRS[@]}" -name test-results -type d) if [[ ${#TEST_RESULT_DIRS[@]} -eq 0 ]]; then echo "No test results found" diff --git a/buildSrc/src/test/kotlin/datadog/gradle/plugin/GradleFixture.kt b/buildSrc/src/test/kotlin/datadog/gradle/plugin/GradleFixture.kt index 3bb1f85f2d5..9401f399170 100644 --- a/buildSrc/src/test/kotlin/datadog/gradle/plugin/GradleFixture.kt +++ b/buildSrc/src/test/kotlin/datadog/gradle/plugin/GradleFixture.kt @@ -23,7 +23,12 @@ internal open class GradleFixture(protected val projectDir: File) { */ fun run(vararg args: String, expectFailure: Boolean = false, env: Map = emptyMap()): BuildResult { val runner = GradleRunner.create() - .withTestKitDir(File(projectDir, ".gradle-test-kit")) + // Use a testkit dir scoped to this fixture's projectDir. The Tooling API always uses a + // daemon and ignores org.gradle.daemon=false. By giving each test its own testkit dir, + // we force a fresh daemon per test — ensuring withEnvironment() vars (e.g. + // MAVEN_REPOSITORY_PROXY) are correctly set on the daemon JVM and not inherited from + // a previously-started daemon with a different test's environment. + .withTestKitDir(file(".testkit")) .withPluginClasspath() .withProjectDir(projectDir) .withEnvironment(System.getenv() + env)