diff --git a/build.gradle b/build.gradle index b1d548f..62654bc 100755 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,6 @@ cveHandler { } dependencies { - implementation 'com.wooga.gradle:gradle-commons:[1,2[' + implementation 'com.wooga.gradle:gradle-commons:[1.5.1,2[' testImplementation 'com.wooga.gradle:gradle-commons-test:[1,2[' } diff --git a/src/integrationTest/groovy/wooga/gradle/fastlane/FastlaneIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/fastlane/FastlaneIntegrationSpec.groovy index 42c3295..3167c0c 100644 --- a/src/integrationTest/groovy/wooga/gradle/fastlane/FastlaneIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/fastlane/FastlaneIntegrationSpec.groovy @@ -16,6 +16,7 @@ package wooga.gradle.fastlane +import com.wooga.gradle.test.BatchmodeWrapper import java.nio.file.Paths @@ -25,14 +26,9 @@ abstract class FastlaneIntegrationSpec extends IntegrationSpec { File fastlaneMockPath def setupFastlaneMock() { - fastlaneMockPath = File.createTempDir("fastlane", "mock") - fastlaneMock = createFile("fastlane", fastlaneMockPath) - fastlaneMock.executable = true - fastlaneMock << """ - #!/usr/bin/env bash - echo \$@ - env - """.stripIndent() + fastlaneMock = new BatchmodeWrapper("fastlane").withEnvironment(true).toTempFile() + fastlaneMockPath = fastlaneMock.parentFile + } def setup() { @@ -43,8 +39,6 @@ abstract class FastlaneIntegrationSpec extends IntegrationSpec { """.stripIndent() } - - // TODO: Replace with newer test API. subStr is an object since we invoke this for any types then discard Object substitutePath(Object expectedValue, Object value, String typeName) { diff --git a/src/integrationTest/groovy/wooga/gradle/fastlane/tasks/SighRenewIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/fastlane/tasks/SighRenewIntegrationSpec.groovy index eec106f..085d56b 100644 --- a/src/integrationTest/groovy/wooga/gradle/fastlane/tasks/SighRenewIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/fastlane/tasks/SighRenewIntegrationSpec.groovy @@ -43,31 +43,28 @@ class SighRenewIntegrationSpec extends AbstractFastlaneTaskIntegrationSpec { @Unroll("property #property #valueMessage sets flag #expectedCommandlineFlag") def "constructs arguments"() { - given: "a task to read the build arguments" - buildFile << """ - task("readValue") { - doLast { - println("arguments: " + ${getTestTaskName()}.arguments.get().join(" ")) - } - } - """.stripIndent() - - and: "a set property" + given: "a set property" if (method != _) { buildFile << """ ${getTestTaskName()}.${method}($value) """.stripIndent() } + and: "a fix for an unknown file" + if(property == "apiKeyPath") { + createFile(rawValue.toString()) + } + // TODO: Refactor and: "a substitution" expectedCommandlineFlag = substitutePath(expectedCommandlineFlag, rawValue, type) when: - def result = runTasksSuccessfully("readValue") + def result = runTasksSuccessfully(testTaskName) then: - outputContains(result, expectedCommandlineFlag) + def argumentsLine = result.standardOutput.split(/\[ARGUMENTS\]\:${System.getProperty("line.separator")}/).last().readLines().first() + argumentsLine.contains(expectedCommandlineFlag) where: property | method | rawValue | type || expectedCommandlineFlag @@ -86,25 +83,16 @@ class SighRenewIntegrationSpec extends AbstractFastlaneTaskIntegrationSpec { "ignoreProfilesWithDifferentName" | "ignoreProfilesWithDifferentName.set" | false | "Boolean" || "--ignore_profiles_with_different_name false" "ignoreProfilesWithDifferentName" | _ | _ | "Boolean" || "--ignore_profiles_with_different_name false" "fileName" | "fileName.set" | "test2.mobileprovisioning" | "String" || "--filename test2.mobileprovisioning" - "destinationDir" | "destinationDir.set" | "/some/path" | "File" || "--output_path /some/path" + "destinationDir" | "destinationDir.set" | "some/path" | "File" || "--output_path some/path" "additionalArguments" | "setAdditionalArguments" | ["--verbose", "--foo bar"] | "List" || "--verbose --foo bar" - "apiKeyPath" | "apiKeyPath.set" | "/path/to/key.json" | "File" || "--api-key-path /path/to/key.json" + "apiKeyPath" | "apiKeyPath.set" | "path/to/key.json" | "File" || "--api-key-path path/to/key.json" value = wrapValueBasedOnType(rawValue, type) valueMessage = (rawValue != _) ? "with value ${value}" : "without value" } @Unroll("property #property #valueMessage sets environment #expectedEnvironmentPair") def "constructs process environment"() { - given: "a task to read the build arguments" - buildFile << """ - task("readValue") { - doLast { - println("arguments: " + ${getTestTaskName()}.environment.get().collect {k,v -> k + '=' + v}.join("\\n")) - } - } - """.stripIndent() - - and: "a set property" + given: "a set property" if (method != _) { buildFile << """ ${getTestTaskName()}.${method}($value) @@ -112,15 +100,16 @@ class SighRenewIntegrationSpec extends AbstractFastlaneTaskIntegrationSpec { } when: - def result = runTasksSuccessfully("readValue") + def result = runTasksSuccessfully(testTaskName) then: - outputContains(result, expectedEnvironmentPair) + def environmentsLines = result.standardOutput.split(/\[ENVIRONMENT\]\:${System.getProperty("line.separator")}/).last().readLines() + environmentsLines.contains(expectedEnvironmentPair) where: property | method | rawValue | type || expectedEnvironmentPair "password" | "password.set" | "secretValue" | "String" || "FASTLANE_PASSWORD=secretValue" - "skip2faUpgrade" | "skip2faUpgrade.set" | true | "BOLEAN" || "SPACESHIP_SKIP_2FA_UPGRADE=1" + "skip2faUpgrade" | "skip2faUpgrade.set" | true | "Bolean" || "SPACESHIP_SKIP_2FA_UPGRADE=1" value = wrapValueBasedOnType(rawValue, type) valueMessage = (rawValue != _) ? "with value ${value}" : "without value" }