forked from Quick/Nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·140 lines (120 loc) · 4.78 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
GREEN="\033[0;32m"
CLEAR="\033[0m"
if which xcodebuild > /dev/null; then
echo -e "Gathering ${GREEN}xcodebuild sdk versions${CLEAR}..."
BUILD_DIR=`pwd`/build
LATEST_IOS_SDK_VERSION=`xcodebuild -showsdks | grep iphonesimulator | cut -d ' ' -f 4 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
LATEST_TVOS_SDK_VERSION=`xcodebuild -showsdks | grep appletvsimulator | cut -d ' ' -f 4 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
LATEST_OSX_SDK_VERSION=`xcodebuild -showsdks | grep 'macosx' | cut -d ' ' -f 3 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
BUILD_IOS_SDK_VERSION=${NIMBLE_BUILD_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION}
RUNTIME_IOS_SDK_VERSION=${NIMBLE_RUNTIME_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION}
BUILD_TVOS_SDK_VERSION=${NIMBLE_BUILD_TVOS_SDK_VERSION:-$LATEST_TVOS_SDK_VERSION}
RUNTIME_TVOS_SDK_VERSION=${NIMBLE_RUNTIME_TVOS_SDK_VERSION:-$LATEST_TVOS_SDK_VERSION}
BUILD_OSX_SDK_VERSION=${NIMBLE_BUILD_OSX_SDK_VERSION:-$LATEST_OSX_SDK_VERSION}
fi
set -e
function color_if_overridden {
local actual=$1
local env_var=$2
if [ -z "$env_var" ]; then
printf "$actual"
else
printf "$GREEN$actual$CLEAR"
fi
}
function print_env {
echo "=== Environment ==="
echo " iOS:"
echo " Latest iOS SDK: $LATEST_IOS_SDK_VERSION"
echo " Building with iOS SDK: `color_if_overridden $BUILD_IOS_SDK_VERSION $NIMBLE_BUILD_IOS_SDK_VERSION`"
echo " Running with iOS SDK: `color_if_overridden $RUNTIME_IOS_SDK_VERSION $NIMBLE_RUNTIME_IOS_SDK_VERSION`"
echo
echo " tvOS:"
echo " Latest tvOS SDK: $LATEST_TVOS_SDK_VERSION"
echo " Building with tvOS SDK: `color_if_overridden $BUILD_TVOS_SDK_VERSION $NIMBLE_BUILD_TVOS_SDK_VERSION`"
echo " Running with tvOS SDK: `color_if_overridden $RUNTIME_TVOS_SDK_VERSION $NIMBLE_RUNTIME_TVOS_SDK_VERSION`"
echo
echo " Mac OS X:"
echo " Latest OS X SDK: $LATEST_OSX_SDK_VERSION"
echo " Building with OS X SDK: `color_if_overridden $BUILD_OSX_SDK_VERSION $NIMBLE_BUILD_OSX_SDK_VERSION`"
echo
echo "======= END ======="
echo
}
function run {
echo -e "$GREEN==>$CLEAR $@"
"$@"
}
function test_ios {
run osascript -e 'tell app "Simulator" to quit'
run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-iOS" -configuration "Debug" -sdk "iphonesimulator$BUILD_IOS_SDK_VERSION" -destination "name=iPad Air,OS=$RUNTIME_IOS_SDK_VERSION" build test
run osascript -e 'tell app "Simulator" to quit'
run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-iOS" -configuration "Debug" -sdk "iphonesimulator$BUILD_IOS_SDK_VERSION" -destination "name=iPhone 5s,OS=$RUNTIME_IOS_SDK_VERSION" build test
}
function test_tvos {
run osascript -e 'tell app "Simulator" to quit'
run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-tvOS" -configuration "Debug" -sdk "appletvsimulator$BUILD_TVOS_SDK_VERSION" -destination "name=Apple TV 1080p,OS=$RUNTIME_TVOS_SDK_VERSION" build test
}
function test_osx {
run xcodebuild -project Nimble.xcodeproj -scheme "Nimble-OSX" -configuration "Debug" -sdk "macosx$BUILD_OSX_SDK_VERSION" build test
}
function test_podspec {
echo "Gathering CocoaPods installation information..."
run bundle exec pod --version
echo "Linting podspec..."
run bundle exec pod lib lint Nimble.podspec
}
function test_swiftpm {
run swift build --clean && swift build && swift test
}
function test() {
test_ios
test_tvos
test_osx
if which swift-test; then
test_swiftpm
else
echo "Not testing with the Swift Package Manager because swift-test is not installed"
fi
}
function clean {
run rm -rf ~/Library/Developer/Xcode/DerivedData\; true
}
function help {
echo "Usage: $0 COMMANDS"
echo
echo "COMMANDS:"
echo " clean - Cleans the derived data directory of Xcode. Assumes default location"
echo " ios - Runs the tests as an iOS device"
echo " tvos - Runs the tests as an tvOS device"
echo " osx - Runs the tests on Mac OS X 10.10 (Yosemite and newer only)"
echo " podspec - Runs pod lib lint against the podspec to detect breaking changes"
echo " all - Runs the all tests of ios, tvos and osx"
echo " swiftpm - Runs the tests built by the Swift Package Manager"
echo " help - Displays this help"
echo
exit 1
}
function main {
print_env
for arg in $@
do
case "$arg" in
clean) clean ;;
ios) test_ios ;;
tvos) test_tvos ;;
osx) test_osx ;;
podspec) test_podspec ;;
test) test ;;
all) test ;;
swiftpm) test_swiftpm ;;
help) help ;;
esac
done
if [ $# -eq 0 ]; then
clean
test
fi
}
main $@