-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a consumer adds a `captureBuildScanLink` method implementation to the init-script, this method will be notified with links for all build scans published by the build.
- Loading branch information
Showing
4 changed files
with
148 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.gradle | ||
|
||
import org.gradle.testkit.runner.BuildResult | ||
import spock.lang.Requires | ||
|
||
class TestBuildScanCapture extends BaseInitScriptTest { | ||
|
||
@Requires({data.testGradleVersion.compatibleWithCurrentJvm}) | ||
def "does not capture build scan url when init-script not enabled"() { | ||
given: | ||
captureBuildScanUrls() | ||
|
||
when: | ||
def result = run(['help'], testGradleVersion.gradleVersion, [:]) | ||
|
||
then: | ||
buildScanUrlIsNotCaptured(result) | ||
|
||
where: | ||
testGradleVersion << ALL_VERSIONS | ||
} | ||
|
||
@Requires({data.testGradleVersion.compatibleWithCurrentJvm}) | ||
def "can capture build scan url with develocity injection"() { | ||
given: | ||
captureBuildScanUrls() | ||
|
||
when: | ||
def config = TestDevelocityInjection.createTestConfig(mockScansServer.address, DEVELOCITY_PLUGIN_VERSION) | ||
def result = run(['help'], testGradleVersion.gradleVersion, config.envVars) | ||
|
||
then: | ||
buildScanUrlIsCaptured(result) | ||
|
||
where: | ||
testGradleVersion << ALL_VERSIONS | ||
} | ||
|
||
@Requires({data.testGradleVersion.compatibleWithCurrentJvm}) | ||
def "can capture build scan url without develocity injection"() { | ||
given: | ||
captureBuildScanUrls() | ||
declareDevelocityPluginApplication(testGradleVersion.gradleVersion) | ||
|
||
when: | ||
def config = new MinimalTestConfig() | ||
def result = run(['help'], testGradleVersion.gradleVersion, config.envVars) | ||
|
||
then: | ||
buildScanUrlIsCaptured(result) | ||
|
||
where: | ||
testGradleVersion << ALL_VERSIONS | ||
} | ||
|
||
void buildScanUrlIsCaptured(BuildResult result) { | ||
def message = "BUILD_SCAN_URL='${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID'" | ||
assert result.output.contains(message) | ||
assert 1 == result.output.count(message) | ||
} | ||
|
||
void buildScanUrlIsNotCaptured(BuildResult result) { | ||
def message = "BUILD_SCAN_URL='${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID'" | ||
assert !result.output.contains(message) | ||
} | ||
|
||
void captureBuildScanUrls() { | ||
initScriptFile << ''' | ||
def captureBuildScanUrl(String buildScanUrl) { | ||
println "BUILD_SCAN_URL='${buildScanUrl}'" | ||
} | ||
''' | ||
} | ||
|
||
static class MinimalTestConfig { | ||
Map<String, String> getEnvVars() { | ||
Map<String, String> envVars = [ | ||
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : "develocity-injection.init.gradle", | ||
] | ||
return envVars | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters