forked from Automattic/wp-e2e-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-mobile.sh
executable file
·96 lines (85 loc) · 1.63 KB
/
run-mobile.sh
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
#!/bin/bash
cd "$(dirname "$0")"
MOCHA=./node_modules/mocha/bin/mocha
REPORTER=""
AFTER="lib/after.js"
OPTS=""
DEVICE="ios92"
CLEAN=0
RETURN=0
declare -a TARGETS
declare -a ORIENTATIONS
# Hard coded to just the specs-ios directory, will change if/when we add something else like visdiff or i18n tests
TARGETS+=("specs-ios/")
usage () {
cat <<EOF
-R - Use custom Slack/Spec/XUnit reporter, otherwise just use Spec reporter
-c - Exit with status code 0 regardless of test results
-p - Portrait orientation
-l - Landscape orientation
-s - Use SauceLabs
-h - This help listing
EOF
exit 0
}
if [ $# -eq 0 ]; then
usage
fi
while getopts ":Rplscd:h" opt; do
case $opt in
R)
REPORTER="-R spec-xunit-slack-reporter"
continue
;;
c)
CLEAN=1
continue
;;
p)
ORIENTATIONS+=("PORTRAIT")
continue
;;
l)
ORIENTATIONS+=("LANDSCAPE")
continue
;;
s)
NC="--NODE_CONFIG='{\"sauce\":true}'"
continue
;;
d)
DEVICE=$OPTARG
continue
;;
h)
usage
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo ""
usage
;;
:)
echo "Option -$OPTARG requires an argument" >&2
echo ""
usage
;;
esac
TARGETS+=("$TARGET")
done
if [ ${#ORIENTATIONS[@]} == 0 ]; then
echo "Must supply at least one -p or -l" >&2
echo ""
usage
fi
for orientation in "${ORIENTATIONS[@]}"; do
for target in "${TARGETS[@]}"; do
CMD="env ORIENTATION=$orientation DEVICE=$DEVICE $MOCHA $NC $REPORTER $target $AFTER"
echo $CMD
RETURN+=$?
done
done
if [ $CLEAN == 1 ]; then
exit 0
fi
exit $RETURN