Skip to content

Commit 0cf5346

Browse files
committed
Add support for travis to run different kinds of tests
1 parent 24f8200 commit 0cf5346

File tree

3 files changed

+104
-74
lines changed

3 files changed

+104
-74
lines changed

Diff for: .travis.sh

+10-62
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,23 @@
22

33
set -eu
44

5-
if [[ "$#" -ne 2 ]]; then
6-
echo "Usage: $0 {iOS|OSX|tvOS} {Debug|Release|Both}"
5+
if [[ "$#" -lt 2 ]]; then
6+
echo "Usage: $0 {Xcode|Pod} [Test type specific parameters]"
77
exit 10
88
fi
99

10-
readonly BUILD_MODE="$1"
11-
readonly BUILD_CFG="$2"
10+
readonly TEST_TYPE="$1"
11+
shift
1212

13-
# Default to "test", changed via BUILD_MODE below.
14-
XCODEBUILD_ACTION="test"
15-
16-
# Report then run the build
17-
RunXcodeBuild() {
18-
echo xcodebuild "$@"
19-
xcodebuild "$@"
20-
}
21-
22-
case "${BUILD_MODE}" in
23-
iOSCore)
24-
CMD_BUILDER+=(
25-
-project Source/GTLRCore.xcodeproj
26-
-scheme "iOS Framework and Tests"
27-
-destination "platform=iOS Simulator,name=iPhone 6,OS=latest"
28-
)
29-
;;
30-
OSXCore)
31-
CMD_BUILDER+=(
32-
-project Source/GTLRCore.xcodeproj
33-
-scheme "OS X Framework and Tests"
34-
)
13+
case "${TEST_TYPE}" in
14+
Xcode)
15+
exec Tests/xcode_tests.sh "$@"
3516
;;
36-
tvOSCore)
37-
CMD_BUILDER+=(
38-
-project Source/GTLRCore.xcodeproj
39-
-scheme "tvOS Framework and Tests"
40-
-destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=latest"
41-
)
42-
;;
43-
ServiceGenerator)
44-
CMD_BUILDER+=(
45-
-project "Source/Tools/ServiceGenerator/ServiceGenerator.xcodeproj"
46-
-scheme "ServiceGenerator"
47-
)
48-
XCODEBUILD_ACTION="build"
49-
;;
50-
Example_*)
51-
EXAMPLE_NAME="${BUILD_MODE/Example_/}"
52-
CMD_BUILDER+=(
53-
-project "Examples/${EXAMPLE_NAME}/${EXAMPLE_NAME}.xcodeproj"
54-
-scheme "${EXAMPLE_NAME}"
55-
)
56-
XCODEBUILD_ACTION="build"
17+
Pod)
18+
exec Tests/pod_integration_tests.sh "$@"
5719
;;
5820
*)
59-
echo "Unknown BUILD_MODE: ${BUILD_MODE}"
21+
echo "Unknown TEST_TYPE: ${TEST_TYPE}"
6022
exit 11
6123
;;
6224
esac
63-
64-
case "${BUILD_CFG}" in
65-
Debug|Release)
66-
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration "${BUILD_CFG}" "${XCODEBUILD_ACTION}"
67-
;;
68-
Both)
69-
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration Debug "${XCODEBUILD_ACTION}"
70-
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration Release "${XCODEBUILD_ACTION}"
71-
;;
72-
*)
73-
echo "Unknown BUILD_CFG: ${BUILD_CFG}"
74-
exit 12
75-
;;
76-
esac

Diff for: .travis.yml

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
language: objective-c
22
osx_image: xcode8.3
33
env:
4-
- MODE=OSXCore CFG=Debug
5-
- MODE=OSXCore CFG=Release
6-
- MODE=iOSCore CFG=Debug
7-
- MODE=iOSCore CFG=Release
8-
- MODE=tvOSCore CFG=Debug
9-
- MODE=tvOSCore CFG=Release
10-
- MODE=ServiceGenerator CFG=Both
11-
- MODE=Example_CalendarSample CFG=Both
12-
- MODE=Example_DriveSample CFG=Both
13-
- MODE=Example_YouTubeSample CFG=Both
14-
- MODE=Example_StorageSample CFG=Both
4+
- TEST_TYPE=Xcode MODE=OSXCore CFG=Debug
5+
- TEST_TYPE=Xcode MODE=OSXCore CFG=Release
6+
- TEST_TYPE=Xcode MODE=iOSCore CFG=Debug
7+
- TEST_TYPE=Xcode MODE=iOSCore CFG=Release
8+
- TEST_TYPE=Xcode MODE=tvOSCore CFG=Debug
9+
- TEST_TYPE=Xcode MODE=tvOSCore CFG=Release
10+
- TEST_TYPE=Xcode MODE=ServiceGenerator CFG=Both
11+
- TEST_TYPE=Xcode MODE=Example_CalendarSample CFG=Both
12+
- TEST_TYPE=Xcode MODE=Example_DriveSample CFG=Both
13+
- TEST_TYPE=Xcode MODE=Example_YouTubeSample CFG=Both
14+
- TEST_TYPE=Xcode MODE=Example_StorageSample CFG=Both
15+
- TEST_TYPE=Pod MODE=ios CFG=Debug
16+
- TEST_TYPE=Pod MODE=ios CFG=Release
17+
- TEST_TYPE=Pod MODE=osx CFG=Debug
18+
- TEST_TYPE=Pod MODE=osx CFG=Release
19+
- TEST_TYPE=Pod MODE=tvos CFG=Debug
20+
- TEST_TYPE=Pod MODE=tvos CFG=Release
1521
script:
16-
- ./.travis.sh "${MODE}" "${CFG}"
22+
- ./.travis.sh "${TEST_TYPE}" "${MODE}" "${CFG}"
1723
notifications:
1824
email: false

Diff for: Tests/xcode_tests.sh

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
if [[ "$#" -ne 2 ]]; then
6+
echo "Usage: $0 {iOS|OSX|tvOS} {Debug|Release|Both}"
7+
exit 10
8+
fi
9+
10+
readonly BUILD_MODE="$1"
11+
readonly BUILD_CFG="$2"
12+
13+
# Default to "test", changed via BUILD_MODE below.
14+
XCODEBUILD_ACTION="test"
15+
16+
# Report then run the build
17+
RunXcodeBuild() {
18+
echo xcodebuild "$@"
19+
xcodebuild "$@"
20+
}
21+
22+
case "${BUILD_MODE}" in
23+
iOSCore)
24+
CMD_BUILDER+=(
25+
-project Source/GTLRCore.xcodeproj
26+
-scheme "iOS Framework and Tests"
27+
-destination "platform=iOS Simulator,name=iPhone 6,OS=latest"
28+
)
29+
;;
30+
OSXCore)
31+
CMD_BUILDER+=(
32+
-project Source/GTLRCore.xcodeproj
33+
-scheme "OS X Framework and Tests"
34+
)
35+
;;
36+
tvOSCore)
37+
CMD_BUILDER+=(
38+
-project Source/GTLRCore.xcodeproj
39+
-scheme "tvOS Framework and Tests"
40+
-destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=latest"
41+
)
42+
;;
43+
ServiceGenerator)
44+
CMD_BUILDER+=(
45+
-project "Source/Tools/ServiceGenerator/ServiceGenerator.xcodeproj"
46+
-scheme "ServiceGenerator"
47+
)
48+
XCODEBUILD_ACTION="build"
49+
;;
50+
Example_*)
51+
EXAMPLE_NAME="${BUILD_MODE/Example_/}"
52+
CMD_BUILDER+=(
53+
-project "Examples/${EXAMPLE_NAME}/${EXAMPLE_NAME}.xcodeproj"
54+
-scheme "${EXAMPLE_NAME}"
55+
)
56+
XCODEBUILD_ACTION="build"
57+
;;
58+
*)
59+
echo "Unknown BUILD_MODE: ${BUILD_MODE}"
60+
exit 11
61+
;;
62+
esac
63+
64+
case "${BUILD_CFG}" in
65+
Debug|Release)
66+
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration "${BUILD_CFG}" "${XCODEBUILD_ACTION}"
67+
;;
68+
Both)
69+
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration Debug "${XCODEBUILD_ACTION}"
70+
RunXcodeBuild "${CMD_BUILDER[@]}" -configuration Release "${XCODEBUILD_ACTION}"
71+
;;
72+
*)
73+
echo "Unknown BUILD_CFG: ${BUILD_CFG}"
74+
exit 12
75+
;;
76+
esac

0 commit comments

Comments
 (0)