-
Notifications
You must be signed in to change notification settings - Fork 78
/
test.sh
executable file
·45 lines (38 loc) · 1.34 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
#!/bin/bash
set -e
echo "" > coverage.txt
echo $TEST_RACE
os=$(go env GOOS)
if [ "$TEST_PD" = "true" ]; then
TESTDIRS=$(go list ./... | grep -v vendor)
else
TESTDIRS=$(go list ./... | grep -v pdserver | grep -v vendor)
fi
echo $TESTDIRS
CGO_CFLAGS="-I${ROCKSDB}/include"
CGO_LDFLAGS="-L${ROCKSDB} -lrocksdb -lstdc++ -lm -lsnappy -ljemalloc"
if [ "$os" == "linux" ]; then
CGO_LDFLAGS="-L${ROCKSDB} -lrocksdb -lstdc++ -lm -lsnappy -lrt -ljemalloc -ldl"
fi
echo $CGO_LDFLAGS
if [ "$TEST_RACE" = "false" ]; then
GOMAXPROCS=1 CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} go test -timeout 1500s $TESTDIRS
else
GOMAXPROCS=4 CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} go test -timeout 1500s -race $TESTDIRS
for d in $TESTDIRS; do
GOMAXPROCS=4 CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} go test -timeout 1500s -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
fi
# no tests, but a build is something
for dir in $(find apps tools -maxdepth 1 -type d) ; do
if grep -q '^package main$' $dir/*.go 2>/dev/null; then
echo "building $dir"
CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} go build -o $dir/$(basename $dir) ./$dir
else
echo "(skipped $dir)"
fi
done