forked from ably/ably-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·62 lines (52 loc) · 1.32 KB
/
test.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
#!/usr/bin/env bash
#
# A script to run the tests.
usage() {
cat <<EOF
usage: $0 [-h|--help] [-p|--protocol PROTOCOL]
Run the ably-go tests.
OPTIONS:
-h, --help Show this message
-p, --protocol PROTOCOL Run tests using PROTOCOL (either 'application/json' or 'application/x-msgpack', default is to run both)
EOF
}
main() {
local protocol=""
# parse the flags
while true; do
case "$1" in
-p | --protocol)
if [[ -z "$2" ]]; then
usage
exit 1
fi
protocol="$2"
shift 2
;;
-h | --help)
usage
exit 0
;;
*)
break
;;
esac
done
# run an individual protocol if requested, or all protocols
if [[ -n "${protocol}" ]]; then
run_tests "${protocol}"
else
for protocol in application/json application/x-msgpack; do
run_tests "${protocol}"
done
fi
}
# Run tests with a specific protocol.
# The -race flag enables Go's Data Race Detector: https://golang.org/doc/articles/race_detector
# The -p option specifies that we only want a single test binary running at any single time.
run_tests() {
local protocol=$1
echo "$(date +%H:%M:%S) - Running ably-go tests with protocol=${protocol}"
ABLY_PROTOCOL="${protocol}" go test -p 1 -race -v -timeout 120m ./...
}
main "$@"