Permalink
Browse files

test script support sub dir test.

  • Loading branch information...
jolestar committed Nov 4, 2016
1 parent 7c0fb89 commit f6e787d56005138cb6937d39b4f65116d83becf7
Showing with 25 additions and 3 deletions.
  1. +1 −1 env
  2. +24 −2 test
View
2 env
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
ORG_PATH="github.com/yunify"
ORG_PATH="github.com/kelseyhightower"
REPO_PATH="${ORG_PATH}/confd"
function gen_version {
View
26 test
@@ -1,4 +1,26 @@
#!/usr/bin/env bash
echo "Running tests..."
go test
source ./env
IGNORE_PKGS="(vendor)"
TEST_PKGS=`find . -name \*_test.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
INTEGRATION_PKGS="(integration|contrib)"
COVER=${COVER:-"-cover"}
TESTABLE=`echo "$TEST_PKGS" | egrep -v "$INTEGRATION_PKGS"`
if [ -z "$PKG" ]; then
TEST=$TESTABLE
else
# strip out leading dotslashes and trailing slashes from PKG=./foo/
TEST=${PKG/#./}
TEST=${TEST/#\//}
TEST=${TEST/%\//}
fi
# split TEST into an array and prepend REPO_PATH to each local package
split=(${TEST// / })
TEST=${split[@]/#/${REPO_PATH}/}
echo "Running tests... ${TEST}"
#--race -cpu 1,2,4
go test --race --cpu 4 -timeout 3m ${COVER} -run=Test $@ ${TEST}

0 comments on commit f6e787d

Please sign in to comment.