forked from sensu/sensu-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (58 loc) · 1.24 KB
/
build.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
#!/usr/bin/env bash
set -o pipefail
set -e
# On CircleCI, we want to see what commands are being run, at least for now
test -n "$CIRCLECI" && set -x
eval $(go env)
cmd=${1:-"all"}
RACE=""
set_race_flag() {
if [ "$GOARCH" == "amd64" ] && [ "$CGO_ENABLED" == "1" ]; then
RACE="-race"
fi
}
case "$GOOS" in
darwin)
set_race_flag
;;
freebsd)
set_race_flag
;;
linux)
set_race_flag
;;
windows)
set_race_flag
;;
esac
unit_test_commands () {
echo "Running unit tests..."
go test -timeout=60s $RACE $(go list ./... | egrep -v '(testing|vendor|scripts)')
if [ $? -ne 0 ]; then
echo "Unit testing failed..."
exit 1
fi
}
integration_test_commands () {
echo "Running integration tests..."
go test -timeout=180s -tags=integration $(go list ./... | egrep -v '(testing|vendor|scripts)')
if [ $? -ne 0 ]; then
echo "Integration testing failed..."
exit 1
fi
}
case "$cmd" in
"none")
echo "noop"
;;
"unit")
unit_test_commands
;;
"integration")
integration_test_commands
;;
*)
unit_test_commands
integration_test_commands
;;
esac