6
6
# ./test
7
7
# ./test -v
8
8
#
9
- # Run tests for one package
10
- #
11
- # PKG=./wal ./test
12
- # PKG=snap ./test
13
- #
14
9
# Run also integration tests
15
- # INTEGRATION=1 ./test
10
+ # INTEGRATION=1 STOLON_TEST_STORE_BACKEND=etcdv3 ./test
16
11
#
17
12
set -e
18
13
@@ -23,58 +18,49 @@ if [ $PWD != $BASEDIR ]; then
23
18
cd $BASEDIR
24
19
fi
25
20
26
- source ./build
21
+ ORG_PATH=" github.com/sorintlab"
22
+ REPO_PATH=" ${ORG_PATH} /stolon"
27
23
28
- TESTABLE= " cmd/keeper cmd/sentinel cmd/proxy pkg/cluster pkg/store pkg/flagutil pkg/postgresql pkg/util "
24
+ ./build
29
25
30
- # user has not provided PKG override
31
- if [ -z " $PKG " ] ; then
32
- TEST= $TESTABLE
33
- FMT= $TESTABLE
26
+ # Hack to be sure that:
27
+ # * all the dependencies are vendored
28
+ # * if cloned as another repo name it will compile anyway
29
+ export GOPATH= ${PWD} /gopath
34
30
35
- # user has provided PKG override
36
- else
37
- # strip out leading dotslashes and trailing slashes from PKG=./foo/
38
- TEST=${PKG/# ./ }
39
- TEST=${TEST/# \/ / }
40
- TEST=${TEST/% \/ / }
41
-
42
- FMT=$TEST
43
- fi
31
+ # test all packages excluding integration tests
32
+ IGNORE_PKGS=" (vendor/|tests/integration)"
33
+ PACKAGES=$( find . -name \* _test.go | while read -r a; do dirname " $a " ; done | sort | uniq | grep -vE " $IGNORE_PKGS " | sed " s|\./||g" )
44
34
45
- # split TEST into an array and prepend REPO_PATH to each local package
46
- split=(${TEST// / } )
47
- TEST=${split[@]/#/ ${REPO_PATH} / }
48
- split=(${NO_RACE_TEST// / } )
49
- NO_RACE_TEST=${split[@]/#/ ${REPO_PATH} / }
35
+ # prepend REPO_PATH to each local package
36
+ split=$PACKAGES
37
+ PACKAGES=" "
38
+ for a in $split ; do PACKAGES=" $PACKAGES ${REPO_PATH} /${a} " ; done
50
39
51
40
echo " Running tests..."
52
41
53
- # Invoke ./cover for HTML output
54
42
COVER=${COVER:- " -cover" }
55
43
56
44
echo " Checking gofmt..."
57
- fmtRes=$( gofmt -l $FMT )
45
+ fmtRes=$( gofmt -l $( find . -type f -name ' *.go ' ! -path ' ./vendor/* ' ) )
58
46
if [ -n " ${fmtRes} " ]; then
59
47
echo -e " gofmt checking failed:\n${fmtRes} "
60
48
exit 255
61
49
fi
62
50
63
51
echo " Checking govet..."
64
- vetRes=$( go vet $TEST )
52
+ vetRes=$( go vet ${PACKAGES} )
65
53
if [ -n " ${vetRes} " ]; then
66
54
echo -e " govet checking failed:\n${vetRes} "
67
55
exit 255
68
56
fi
69
57
70
58
echo " Checking govet -shadow ..."
71
- for path in $FMT ; do
72
- vetRes=$( go tool vet -shadow ${path} )
73
- if [ -n " ${vetRes} " ]; then
74
- echo -e " govet checking ${path} failed:\n${vetRes} "
75
- exit 255
76
- fi
77
- done
59
+ vetRes=$( go vet -shadow ${PACKAGES} )
60
+ if [ -n " ${vetRes} " ]; then
61
+ echo -e " govet checking ${path} failed:\n${vetRes} "
62
+ exit 255
63
+ fi
78
64
79
65
echo " Checking for license header..."
80
66
licRes=$( for file in $( find . -type f -iname ' *.go' ! -path ' ./vendor/*' ) ; do
@@ -85,7 +71,7 @@ if [ -n "${licRes}" ]; then
85
71
exit 255
86
72
fi
87
73
88
- go test -timeout 3m ${COVER} $@ ${TEST } ${RACE}
74
+ go test -timeout 3m ${COVER} $@ ${PACKAGES } ${RACE}
89
75
90
76
if [ -n " $INTEGRATION " ]; then
91
77
echo " Running integration tests..."
0 commit comments