-
Notifications
You must be signed in to change notification settings - Fork 999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand Test Execution Coverage #979
Changes from all commits
3bdab3c
7ef38f5
fd1a3e8
4a00bf0
5084fd6
7ecf345
2fc6b5b
2321d49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
function info { | ||
echo "[$(basename "${0}")] [INFO] ${1}" | ||
} | ||
|
||
function die { | ||
echo "[$(basename "${0}")] [ERROR] ${1}" | ||
exit 1 | ||
} | ||
|
||
# Verify xcpretty is installed | ||
if ! command -v xcpretty > /dev/null; then | ||
if [[ "${CI}" != "true" ]]; then | ||
die "Please install xcpretty: https://github.com/supermarin/xcpretty#installation" | ||
fi | ||
|
||
info "Installing xcpretty..." | ||
gem install xcpretty --no-ri --no-rdoc || die "Executing \`gem install xcpretty\` failed" | ||
fi | ||
|
||
# Install sample app dependencies | ||
info "Installing sample app dependencies..." | ||
|
||
cd "Example" || die "Executing \`cd\` failed" | ||
carthage bootstrap --platform iOS | ||
carthage_exit_code="$?" | ||
cd .. || die "Executing \`cd\` failed" | ||
|
||
if [[ "${carthage_exit_code}" != 0 ]]; then | ||
die "Executing carthage failed with status code: ${carthage_exit_code}" | ||
fi | ||
|
||
# Execute sample app builds (iPhone 6, iOS 11.x) | ||
info "Executing sample app builds (iPhone 6, iOS 11.x)..." | ||
|
||
xcodebuild build \ | ||
-workspace "Stripe.xcworkspace" \ | ||
-scheme "Standard Integration (Swift)" \ | ||
-sdk "iphonesimulator" \ | ||
-destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ | ||
| xcpretty | ||
|
||
exit_code="${PIPESTATUS[0]}" | ||
|
||
if [[ "${exit_code}" != 0 ]]; then | ||
die "xcodebuild exited with non-zero status code: ${exit_code}" | ||
fi | ||
|
||
xcodebuild build \ | ||
-workspace "Stripe.xcworkspace" \ | ||
-scheme "Custom Integration (ObjC)" \ | ||
-sdk "iphonesimulator" \ | ||
-destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ | ||
| xcpretty | ||
|
||
exit_code="${PIPESTATUS[0]}" | ||
|
||
if [[ "${exit_code}" != 0 ]]; then | ||
die "xcodebuild exited with non-zero status code: ${exit_code}" | ||
fi | ||
|
||
info "All good!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,77 @@ | ||
set -euf -o pipefail | ||
#!/bin/bash | ||
|
||
carthage bootstrap --platform ios --configuration Release --no-use-binaries | ||
cd Example; carthage bootstrap --platform ios; cd .. | ||
function info { | ||
echo "[$(basename "${0}")] [INFO] ${1}" | ||
} | ||
|
||
gem install xcpretty --no-ri --no-rdoc | ||
xcodebuild clean build build-for-testing -workspace Stripe.xcworkspace -scheme "StripeiOS" -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c | ||
xcodebuild test-without-building -workspace Stripe.xcworkspace -scheme "StripeiOS" -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c | ||
xcodebuild build -workspace Stripe.xcworkspace -scheme "Standard Integration (Swift)" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c | ||
xcodebuild build -workspace Stripe.xcworkspace -scheme "Custom Integration (ObjC)" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.2' | xcpretty -c | ||
function die { | ||
echo "[$(basename "${0}")] [ERROR] ${1}" | ||
exit 1 | ||
} | ||
|
||
# Verify xcpretty is installed | ||
if ! command -v xcpretty > /dev/null; then | ||
if [[ "${CI}" != "true" ]]; then | ||
die "Please install xcpretty: https://github.com/supermarin/xcpretty#installation" | ||
fi | ||
|
||
info "Installing xcpretty..." | ||
gem install xcpretty --no-ri --no-rdoc || die "Executing \`gem install xcpretty\` failed" | ||
fi | ||
|
||
# Install test dependencies | ||
info "Installing test dependencies..." | ||
|
||
carthage bootstrap --platform iOS --configuration Release --no-use-binaries | ||
carthage_exit_code="$?" | ||
|
||
if [[ "${carthage_exit_code}" != 0 ]]; then | ||
die "Executing carthage failed with status code: ${carthage_exit_code}" | ||
fi | ||
|
||
# Execute tests (iPhone 6 @ iOS 11.2) | ||
info "Executing tests (iPhone 6 @ iOS 11.2)..." | ||
|
||
xcodebuild clean test \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you combine the build & test steps? They were intentionally separated last year: eb8009a I know I've run into this problem in the past (and have the radar to prove it), but I don't know if it's still an issue in Xcode 9. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i combined it to reduce code duplication, and it seems to work? i think if we need it again in the future, we should leave the reasoning as a comment in the code because a bum like me is going to miss the commit blame. |
||
-workspace "Stripe.xcworkspace" \ | ||
-scheme "StripeiOS" \ | ||
-configuration "Debug" \ | ||
-sdk "iphonesimulator" \ | ||
-destination "platform=iOS Simulator,name=iPhone 6,OS=11.2" \ | ||
| xcpretty | ||
|
||
exit_code="${PIPESTATUS[0]}" | ||
|
||
if [[ "${exit_code}" != 0 ]]; then | ||
die "xcodebuild exited with non-zero status code: ${exit_code}" | ||
fi | ||
|
||
# Execute tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x, iPhone 4s @ iOS 9.x) | ||
# - Skips snapshot tests because they're recorded for the iPhone 6 on the newest iOS version only | ||
# - Not sure why tests STPImageLibraryTest fail on older iOS versions | ||
# - Set `ONLY_ACTIVE_ARCH=NO` to build both 32-bit and 64-bit products | ||
info "Executing tests on legacy devices (iPhone 6 @ iOS 10.x, iPhone 6 @ iOS 9.x, iPhone 4s @ iOS 9.x)..." | ||
|
||
xcodebuild clean test \ | ||
-workspace "Stripe.xcworkspace" \ | ||
-scheme "StripeiOS" \ | ||
-configuration "Debug" \ | ||
-sdk "iphonesimulator" \ | ||
-destination "platform=iOS Simulator,name=iPhone 6,OS=10.3.1" \ | ||
-destination "platform=iOS Simulator,name=iPhone 6,OS=9.3" \ | ||
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.3" \ | ||
-skip-testing:"StripeiOS Tests/STPAddCardViewControllerLocalizationTests" \ | ||
-skip-testing:"StripeiOS Tests/STPPaymentMethodsViewControllerLocalizationTests" \ | ||
-skip-testing:"StripeiOS Tests/STPShippingAddressViewControllerLocalizationTests" \ | ||
-skip-testing:"StripeiOS Tests/STPShippingMethodsViewControllerLocalizationTests" \ | ||
-skip-testing:"StripeiOS Tests/STPImageLibraryTest" \ | ||
ONLY_ACTIVE_ARCH=NO \ | ||
| xcpretty | ||
|
||
exit_code="${PIPESTATUS[0]}" | ||
|
||
if [[ "${exit_code}" != 0 ]]; then | ||
die "xcodebuild exited with non-zero status code: ${exit_code}" | ||
fi | ||
|
||
info "All good!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it intentional to drop the
-c
flag that colorizes the output?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, to me, the default behavior seems to works so why bother specifying it: