Test for GE plugin applied in settingsEvaluated

This commit is contained in:
daz 2023-04-26 10:47:38 -06:00
parent 55d241b8a2
commit a13870c94e
No known key found for this signature in database
2 changed files with 31 additions and 0 deletions

View File

@ -38,6 +38,9 @@ class BaseInitScriptTest extends Specification {
static final List<TestGradleVersion> CONFIGURATION_CACHE_VERSIONS =
[GRADLE_7_X, GRADLE_8_X]
static final List<TestGradleVersion> 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'

View File

@ -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