Skip to content

Commit

Permalink
fixed that the -derivedDataPath is only added if a scheme is set: issue
Browse files Browse the repository at this point in the history
  • Loading branch information
renep committed Aug 8, 2016
1 parent da54f01 commit 827b6d1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 16 deletions.
7 changes: 5 additions & 2 deletions plugin/src/main/groovy/org/openbakery/tools/Xcodebuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ class Xcodebuild {
}

def addBuildPath(ArrayList commandList) {
commandList.add("-derivedDataPath")
commandList.add(parameters.derivedDataPath.absolutePath)
if (parameters.scheme) {
// add this parameter only if a scheme is set
commandList.add("-derivedDataPath")
commandList.add(parameters.derivedDataPath.absolutePath)
}
commandList.add("DSTROOT=" + parameters.dstRoot.absolutePath)
commandList.add("OBJROOT=" + parameters.objRoot.absolutePath)
commandList.add("SYMROOT=" + parameters.symRoot.absolutePath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.openbakery.tools

import org.apache.commons.io.FileUtils
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.openbakery.CommandRunner
Expand Down Expand Up @@ -59,7 +58,7 @@ class XcodebuildSpecification extends Specification {
e.message == "No 'scheme' or 'target' specified, so do not know what to build"
}

def createCommandWithDefaultDirectories(String... commands) {
def createCommandWithDerivedDataPath_And_DefaultDirectories(String... commands) {
def command = []
command.addAll(commands)
command << "-derivedDataPath" << new File("build/derivedData").absolutePath
Expand All @@ -70,6 +69,17 @@ class XcodebuildSpecification extends Specification {
return command
}

def createCommandWithDefaultDirectories(String... commands) {
def command = []
command.addAll(commands)
command << "DSTROOT=" + new File("build/dst").absolutePath
command << "OBJROOT=" + new File("build/obj").absolutePath
command << "SYMROOT=" + new File("build/sym").absolutePath
command << "SHARED_PRECOMPS_DIR=" + new File("build/shared").absolutePath
return command
}


def "run command with expected scheme and expected default directories"() {
def commandList

Expand All @@ -84,7 +94,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_,_,_,_) >> {arguments-> commandList=arguments[1]}

commandList == createCommandWithDefaultDirectories('xcodebuild',
commandList == createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug",
Expand Down Expand Up @@ -171,7 +181,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug",
Expand All @@ -197,7 +207,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug",
Expand Down Expand Up @@ -226,7 +236,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug",
Expand All @@ -253,7 +263,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug",
Expand All @@ -279,7 +289,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", "Debug")
Expand Down Expand Up @@ -329,7 +339,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", 'Debug' )
Expand All @@ -354,7 +364,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", 'Debug',
Expand Down Expand Up @@ -425,7 +435,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", 'Debug',
Expand All @@ -450,7 +460,7 @@ class XcodebuildSpecification extends Specification {
then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('xcodebuild',
"-scheme", 'myscheme',
"-workspace", 'myworkspace',
"-configuration", 'Debug',
Expand Down Expand Up @@ -559,7 +569,7 @@ class XcodebuildSpecification extends Specification {


interaction {
expectedCommandList = createCommandWithDefaultDirectories('script', '-q', '/dev/null',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('script', '-q', '/dev/null',
"xcodebuild",
"-scheme", 'myscheme',
"-workspace", "myworkspace",
Expand Down Expand Up @@ -597,7 +607,7 @@ class XcodebuildSpecification extends Specification {


interaction {
expectedCommandList = createCommandWithDefaultDirectories('script', '-q', '/dev/null',
expectedCommandList = createCommandWithDerivedDataPath_And_DefaultDirectories('script', '-q', '/dev/null',
"xcodebuild",
"-scheme", 'myscheme',
"-workspace", "myworkspace",
Expand All @@ -611,4 +621,30 @@ class XcodebuildSpecification extends Specification {

commandList == expectedCommandList
}



def "run command with target that has no scheme, and must not include derivedDataPath"() {

def commandList
def expectedCommandList

xcodebuild.parameters.target = 'mytarget'
xcodebuild.parameters.workspace = 'myworkspace'

when:
xcodebuild.execute("", outputAppender, null)

then:
1 * commandRunner.run(_, _, _, _) >> { arguments -> commandList = arguments[1] }
interaction {
expectedCommandList = createCommandWithDefaultDirectories('xcodebuild',
"-configuration", "Debug",
"-target", 'mytarget')
expectedCommandList << "-destination" << "platform=iOS Simulator,id=5F371E1E-AFCE-4589-9158-8C439A468E61"
}
commandList == expectedCommandList

}

}

0 comments on commit 827b6d1

Please sign in to comment.