forked from decred/dcrwallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.sh
executable file
·63 lines (53 loc) · 2.11 KB
/
run_tests.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
#!/usr/bin/env bash
set -ex
# The script does automatic checking on a Go package and its sub-packages,
# including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. golint (https://github.com/golang/lint)
# 3. go vet (http://golang.org/cmd/vet)
# 4. gosimple (https://github.com/dominikh/go-simple)
# 5. unconvert (https://github.com/mdempsky/unconvert)
# 6. ineffassign (https://github.com/gordonklaus/ineffassign)
# 7. race detector (http://blog.golang.org/race-detector)
# gometalinter (github.com/alecthomas/gometalinter) is used to run each each
# static checker.
# To run on docker on windows, symlink /mnt/c to /c and then execute the script
# from the repo path under /c. See:
# https://github.com/Microsoft/BashOnWindows/issues/1854
# for more details.
#Default GOVERSION
GOVERSION=${1:-1.9}
REPO=dcrwallet
TESTDIRS=$(go list ./... | grep -v '/vendor/')
TESTCMD="test -z \"\$(gometalinter -j 4 --disable-all \
--enable=gofmt \
--enable=gosimple \
--enable=unconvert \
--enable=ineffassign \
--vendor \
--deadline=10m ./... 2>&1 | egrep -v 'testdata/' | tee /dev/stderr)\" && \
test -z \"\$(gometalinter -j 4 --disable-all \
--enable=golint \
--vendor \
--deadline=10m ./... 2>&1 | egrep -v '(ALL_CAPS|OP_|NewFieldVal|RpcCommand|RpcRawCommand|RpcSend|Dns|api.pb.go|StartConsensusRpc|factory_test.go|legacy|UnstableAPI|_string.go)' | tee /dev/stderr)\" && \
test -z \"\$(gometalinter -j 4 --disable-all \
--enable=vet \
--vendor \
--deadline=10m ./... 2>&1 | egrep -v 'not a string in call to [A-Za-z]+f' | tee /dev/stderr)\" && \
env GORACE='halt_on_error=1' go test -short -race \${TESTDIRS}"
if [ $GOVERSION == "local" ]; then
eval $TESTCMD
exit
fi
DOCKER_IMAGE_TAG=decred-golang-builder-$GOVERSION
docker pull decred/$DOCKER_IMAGE_TAG
docker run --rm -it -v $(pwd):/src decred/$DOCKER_IMAGE_TAG /bin/bash -c "\
rsync -ra --filter=':- .gitignore' \
/src/ /go/src/github.com/decred/$REPO/ && \
cd github.com/decred/$REPO/ && \
dep ensure && \
go install . ./cmd/... && \
$TESTCMD
"
echo "------------------------------------------"
echo "Tests complete."