Skip to content

Commit 72fdbc7

Browse files
committed
Fix fallback to iphonesimulator
In #484 more flags were added into the variable `sdkflag`, which then caused the following execution of run_xctool to always fail. This means that iOS tests have not been running as part of the TravisCI run, they have only been built. You can see this if you look at the final run for the PR: https://travis-ci.org/libgit2/objective-git/builds/78334551#L192 Bash does some great things when trying to interpret variables in commands. Initially the `$sdkflag` didn't have any quotes around it as can be seen in commit 15f906c. When the second flag was added this would have caused the command to fail because of the way Bash would interpret the whitespace. Without the surrounding quotes the command would have been executed as follows: ``` xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO -sdk iphonesimulator -destination '"platform=iOS' Simulator,name=iPhone '5"' -scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO ``` You can see in the above that the white space was split in the middle of the `-destination` parameter and it causes `xctool` to spout out an error. When the surrounding quotes were added it caused xctool to run but `$sdkflag` would be interpretted as a single argument, as it is executed as follows: ``` xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO '-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5"' -scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO ``` Notice in the above that the entire argument is still surrounded by single quotes. This can be solved by switching `$sdkflag` for an array of strings, this can then be correctly expanded in the command getting around the issues highlighted above. You can read more about these issues with Bash in the following links: - http://mywiki.wooledge.org/BashFAQ/050 - http://mywiki.wooledge.org/BashFAQ/073
1 parent d2e3eb7 commit 72fdbc7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

script/cibuild

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ build_scheme ()
118118
echo "*** Building and testing $scheme..."
119119
echo
120120

121-
local sdkflag=
121+
local sdkflags=()
122122
local action=test
123123

124124
# Determine whether we can run unit tests for this target.
@@ -129,17 +129,17 @@ build_scheme ()
129129
if [ "$awkstatus" -eq "1" ]
130130
then
131131
# SDK not found, try for iphonesimulator.
132-
sdkflag='-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5"'
132+
sdkflags=(-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5")
133133

134134
# Determine whether the unit tests will run with iphonesimulator
135-
run_xctool "$sdkflag" -scheme "$scheme" run-tests | parse_build
135+
run_xctool "${sdkflags[@]}" -scheme "$scheme" run-tests | parse_build
136136

137137
awkstatus=$?
138138

139139
if [ "$awkstatus" -ne "0" ]
140140
then
141141
# Unit tests will not run on iphonesimulator.
142-
sdkflag=""
142+
sdkflags=()
143143
fi
144144
fi
145145

@@ -149,7 +149,7 @@ build_scheme ()
149149
action=build
150150
fi
151151

152-
run_xctool $sdkflag -scheme "$scheme" $action
152+
run_xctool "${sdkflags[@]}" -scheme "$scheme" $action
153153
}
154154

155155
export -f build_scheme

0 commit comments

Comments
 (0)