Switch cibuild to xcodebuild and xcpretty

`xctool` runs the tests as logic only whereas `xcodebuild` and XCode
run them as application tests. When tests are running logic only a lot
of the subsystems that would be available on the simulator are not
there, for example keychain and networking.

https://github.com/facebook/xctool/issues/269
https://github.com/AFNetworking/AFNetworking/pull/1707
https://github.com/facebook/xctool/issues/367
https://github.com/facebook/xctool/issues/553
This commit is contained in:
Tom Booth 2016-03-22 22:26:40 +00:00
parent b8885e6509
commit c3b155cfd4
3 changed files with 24 additions and 28 deletions

View File

@ -10,9 +10,12 @@ config ()
{ {
# A whitespace-separated list of executables that must be present and locatable. # A whitespace-separated list of executables that must be present and locatable.
# These will each be installed through Homebrew if not found. # These will each be installed through Homebrew if not found.
: ${REQUIRED_TOOLS="xctool cmake libssh2 libtool autoconf automake pkg-config"} : ${REQUIRED_TOOLS="cmake libssh2 libtool autoconf automake pkg-config"}
: ${REQUIRED_GEMS="xcpretty"}
export REQUIRED_TOOLS export REQUIRED_TOOLS
export REQUIRED_GEMS
} }
## ##
@ -102,6 +105,11 @@ check_deps ()
sudo ln -s "$brew_prefix/$product" "$destination" sudo ln -s "$brew_prefix/$product" "$destination"
done done
fi fi
for gem in $REQUIRED_GEMS
do
gem install "$gem"
done
} }
bootstrap_submodule () bootstrap_submodule ()

View File

@ -13,7 +13,7 @@ config ()
# The workspace to build. # The workspace to build.
# #
# If not set and no workspace is found, the -workspace flag will not be passed # If not set and no workspace is found, the -workspace flag will not be passed
# to `xctool`. # to `xcodebuild`.
# #
# Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will # Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will
# take precedence. # take precedence.
@ -22,7 +22,7 @@ config ()
# The project to build. # The project to build.
# #
# If not set and no project is found, the -project flag will not be passed # If not set and no project is found, the -project flag will not be passed
# to `xctool`. # to `xcodebuild`.
# #
# Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will # Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will
# take precedence. # take precedence.
@ -33,8 +33,8 @@ config ()
# If this file does not exist, it is not considered an error. # If this file does not exist, it is not considered an error.
: ${BOOTSTRAP="$SCRIPT_DIR/bootstrap"} : ${BOOTSTRAP="$SCRIPT_DIR/bootstrap"}
# Extra options to pass to xctool. # Extra options to pass to xcodebuild.
: ${XCTOOL_OPTIONS="RUN_CLANG_STATIC_ANALYZER=NO"} : ${XCODEBUILD_OPTIONS="RUN_CLANG_STATIC_ANALYZER=NO"}
# A whitespace-separated list of default schemes to build. # A whitespace-separated list of default schemes to build.
# #
@ -44,7 +44,7 @@ config ()
export XCWORKSPACE export XCWORKSPACE
export XCODEPROJ export XCODEPROJ
export BOOTSTRAP export BOOTSTRAP
export XCTOOL_OPTIONS export XCODEBUILD_OPTIONS
export SCHEMES export SCHEMES
} }
@ -86,17 +86,17 @@ find_pattern ()
ls -d $1 2>/dev/null | head -n 1 ls -d $1 2>/dev/null | head -n 1
} }
run_xctool () run_xcodebuild ()
{ {
if [ -n "$XCWORKSPACE" ] if [ -n "$XCWORKSPACE" ]
then then
xctool -workspace "$XCWORKSPACE" $XCTOOL_OPTIONS "$@" \ xcodebuild -workspace "$XCWORKSPACE" $XCODEBUILD_OPTIONS "$@" \
ONLY_ACTIVE_ARCH=NO \ ONLY_ACTIVE_ARCH=NO \
CODE_SIGN_IDENTITY="" \ CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO 2>&1 CODE_SIGNING_REQUIRED=NO 2>&1
elif [ -n "$XCODEPROJ" ] elif [ -n "$XCODEPROJ" ]
then then
xctool -project "$XCODEPROJ" $XCTOOL_OPTIONS "$@" \ xcodebuild -project "$XCODEPROJ" $XCODEBUILD_OPTIONS "$@" \
ONLY_ACTIVE_ARCH=NO \ ONLY_ACTIVE_ARCH=NO \
CODE_SIGN_IDENTITY="" \ CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO 2>&1 CODE_SIGNING_REQUIRED=NO 2>&1
@ -108,7 +108,7 @@ run_xctool ()
parse_build () parse_build ()
{ {
awk -f "$SCRIPT_DIR/xctool.awk" 2>&1 >/dev/null awk -f "$SCRIPT_DIR/xcodebuild.awk" 2>&1 >/dev/null
} }
build_scheme () build_scheme ()
@ -122,7 +122,7 @@ build_scheme ()
local action=test local action=test
# Determine whether we can run unit tests for this target. # Determine whether we can run unit tests for this target.
run_xctool -scheme "$scheme" run-tests | parse_build run_xcodebuild -scheme "$scheme" test | parse_build
local awkstatus=$? local awkstatus=$?
@ -132,7 +132,7 @@ build_scheme ()
sdkflags=(-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5") sdkflags=(-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5")
# Determine whether the unit tests will run with iphonesimulator # Determine whether the unit tests will run with iphonesimulator
run_xctool "${sdkflags[@]}" -scheme "$scheme" run-tests | parse_build run_xcodebuild "${sdkflags[@]}" -scheme "$scheme" tests | parse_build
awkstatus=$? awkstatus=$?
@ -149,11 +149,11 @@ build_scheme ()
action=build action=build
fi fi
run_xctool "${sdkflags[@]}" -scheme "$scheme" $action run_xcodebuild "${sdkflags[@]}" -scheme "$scheme" $action | xcpretty
} }
export -f build_scheme export -f build_scheme
export -f run_xctool export -f run_xcodebuild
export -f parse_build export -f parse_build
main main

View File

@ -13,23 +13,11 @@ BEGIN {
fflush(stdout); fflush(stdout);
} }
/is not valid for Testing/ { /A build only device cannot be used to run this target/ {
exit 2; status = 1
}
/[0-9]+: (error|warning):/ {
errors = errors $0 "\n";
}
/(TEST|BUILD) FAILED/ {
status = 1;
} }
END { END {
if (length(errors) > 0) {
print "\n*** All errors:\n" errors;
}
fflush(stdout); fflush(stdout);
exit status; exit status;
} }