forked from akshaykarle/go-mongodbatlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·38 lines (32 loc) · 901 Bytes
/
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
#!/usr/bin/env bash
set -e
PKGS=$(go list ./... | grep -v /examples | xargs -I % basename % | awk '{print "./"$0"/"}')
FORMATTABLE="$(ls -d */)"
LINTABLE=$(go list ./... | xargs -I % basename % | awk '{print "./"$0"/"}')
TESTARGS="-race -coverprofile=profile.out -covermode=atomic"
ROOT_DIR=$(pwd)/
COVERAGE_PATH=${ROOT_DIR}/coverage.txt
echo "Checking gofmt..."
fmtRes=$(gofmt -l $FORMATTABLE)
if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}"
exit 2
fi
echo "" > ${COVERAGE_PATH}
for d in $PKGS; do
go test ${TESTARGS} -v $d
r=$?
if [ $r -ne 0 ]; then
exit $r
elif [ -f profile.out ]; then
cat profile.out >> ${COVERAGE_PATH}
rm profile.out
fi
done
go vet $PKGS
echo "Checking golint..."
lintRes=$(echo $LINTABLE | xargs -n 1 golint)
if [ -n "${lintRes}" ]; then
echo -e "golint checking failed:\n${lintRes}"
exit 2
fi