-
Notifications
You must be signed in to change notification settings - Fork 9
/
test_all
executable file
·59 lines (50 loc) · 1.55 KB
/
test_all
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
#!/bin/bash
if [ "$#" -eq 1 ] && [ "$1" = '--offline' ]; then
printf "Running in offline mode.\n"
printf "Will skip tests which require network.\n"
offline_mode='true'
else
printf "Will NOT skip tests which require network.\n"
offline_mode='false'
fi
printf "Running gofmt tests..."
gofmt_output="$(git ls-files | grep -v "^$(git ls-files -d)\$" | grep -v '^vendor/' | grep '.go$' | xargs gofmt -l 2>&1)"
if [ ! -z "$gofmt_output" ]; then
printf "FAIL. The following files are not gofmt'd:\n$gofmt_output" 1>&2
exit 1
fi
printf "OK\n"
printf "Running 'go install'..."
go_install_output=`go install 2>&1`
if [ "$?" -ne "0" ]; then
printf "FAIL. output:\n$go_install_output\n" 1>&2
exit 1
fi
printf "OK\n"
printf "Running go vet tests..."
go_vet_output="$(go vet -v ./... 2>&1 | grep ':' )"
# grep ':' is a hack-ish way to only match path/to/file.go:lineno:colno: vet msg
if [ ! -z "$go_vet_output" ]; then
printf "FAIL. output:\n$go_vet_output\n" 1>&2
exit 1
fi
printf "OK\n"
printf "Running end-to-end tests...\n"
source ./e2e_tests/lib.sh
if [ "$?" -ne 0 ]; then
printf "FAIL. failed to source './e2e_tests/lib.sh'\n"
exit 1
fi
for test_module in `ls e2e_tests/*.sh | grep -v 'lib.sh'`; do
source "$test_module" # populates the $tests variable
if [ "$?" -ne 0 ]; then
printf "FAIL. failed to source '$test_module'\n"
exit 1
fi
for testcase in "${tests[@]}"; do
setup_test "$testcase"
run_test "$testcase"
done
done
printf "Running 'go test -v ./...'\n"
go test -v ./...