Skip to content

Commit

Permalink
Improve bin/test with more functionality
Browse files Browse the repository at this point in the history
`bin/test` now supports flags to customize the behavior. We can use this
immediately for Circle by outputting JUnit xml that Circle can use to
get some insight into our test suite.
  • Loading branch information
gfontenot committed Nov 7, 2016
1 parent 2347bf9 commit a3872f5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
52 changes: 43 additions & 9 deletions bin/test
@@ -1,31 +1,65 @@
#!/usr/bin/env sh
#!/bin/bash
#
# Runs tests via xcodebuild, formatting results with xcpretty.
#
# Usage: bin/test [options]
#
# Options:
# -k Clean before running the tests.
# -r Emit JUnit XML report.
# -t Use RSpec-style test output.

set -o pipefail
set -eo pipefail

build_actions=(test)
test_reports_dir="${CIRCLE_TEST_REPORTS:-build}"
xcpretty_options=(--color)

while getopts krt opt; do
case ${opt} in
k)
build_actions=(clean test)
;;
r)
xcpretty_options+=(--report junit --output "${test_reports_dir}/test-report.xml")
;;
t)
xcpretty_options+=(--test)
;;
*)
exit 1
;;
esac
done

shift $((OPTIND - 1))

mkdir -p "${test_reports_dir}"

xcrun xcodebuild \
-workspace Argo.xcworkspace \
-scheme Argo-Mac \
test \
| xcpretty --color
"${build_actions[@]}" \
| xcpretty "${xcpretty_options[@]}"

xcrun xcodebuild \
-workspace Argo.xcworkspace \
-scheme Argo-iOS \
-destination "platform=iOS Simulator,name=iPhone 6" \
test \
| xcpretty --color
"${build_actions[@]}" \
| xcpretty "${xcpretty_options[@]}"

xcrun xcodebuild \
-workspace Argo.xcworkspace \
-scheme Argo-watchOS \
-destination "generic/platform=watchOS" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
| xcpretty --color
| xcpretty "${xcpretty_options[@]}"

xcrun xcodebuild \
-workspace Argo.xcworkspace \
-scheme Argo-tvOS \
-destination "platform=tvOS Simulator,name=Apple TV 1080p" \
test \
| xcpretty --color
"${build_actions[@]}" \
| xcpretty "${xcpretty_options[@]}"
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -8,4 +8,4 @@ dependencies:

test:
override:
- bin/test
- bin/test -r

0 comments on commit a3872f5

Please sign in to comment.