From a13870c94ef4746500674e821a7ad834f4b1d1e8 Mon Sep 17 00:00:00 2001 From: daz Date: Wed, 26 Apr 2023 10:47:38 -0600 Subject: [PATCH] Test for GE plugin applied in settingsEvaluated --- .../BaseInitScriptTest.groovy | 3 ++ .../TestBuildResultRecorder.groovy | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/BaseInitScriptTest.groovy b/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/BaseInitScriptTest.groovy index 427b557..8212e0b 100644 --- a/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/BaseInitScriptTest.groovy +++ b/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/BaseInitScriptTest.groovy @@ -38,6 +38,9 @@ class BaseInitScriptTest extends Specification { static final List CONFIGURATION_CACHE_VERSIONS = [GRADLE_7_X, GRADLE_8_X] + static final List SETTINGS_PLUGIN_VERSIONS = + [GRADLE_6_X, GRADLE_7_X, GRADLE_8_X] + static final String PUBLIC_BUILD_SCAN_ID = 'i2wepy2gr7ovw' static final String DEFAULT_SCAN_UPLOAD_TOKEN = 'scan-upload-token' static final String ROOT_PROJECT_NAME = 'test-init-script' diff --git a/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy b/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy index d815202..4cfd4a2 100644 --- a/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy +++ b/test/init-scripts/src/test/groovy/com/gradle/gradlebuildaction/TestBuildResultRecorder.groovy @@ -148,6 +148,34 @@ class TestBuildResultRecorder extends BaseInitScriptTest { testGradleVersion << ALL_VERSIONS } + def "produces build results file with build scan when GE plugin is applied in settingsEvaluated"() { + assumeTrue testGradleVersion.compatibleWithCurrentJvm + + when: + settingsFile.text = """ + plugins { + id 'com.gradle.enterprise' version '3.13' apply(false) + } + gradle.settingsEvaluated { + apply plugin: 'com.gradle.enterprise' + gradleEnterprise { + server = '$mockScansServer.address' + buildScan { + publishAlways() + } + } + } + """ + settingsFile.text + + run(['help'], initScript, testGradleVersion.gradleVersion) + + then: + assertResults('help', testGradleVersion, false, true) + + where: + testGradleVersion << SETTINGS_PLUGIN_VERSIONS + } + void assertResults(String task, TestGradleVersion testGradleVersion, boolean hasFailure, boolean hasBuildScan, boolean scanUploadFailed = false) { def results = new JsonSlurper().parse(buildResultFile) assert results['rootProjectName'] == ROOT_PROJECT_NAME