diff --git a/test/test-gotest.sh b/test/test-gotest.sh index 0b1a2f1e..3f97dbe4 100755 --- a/test/test-gotest.sh +++ b/test/test-gotest.sh @@ -11,7 +11,6 @@ function run-test() } ROOT=$(dirname "${BASH_SOURCE}")/.. - cd "${ROOT}" for pkg in `go list ./... | grep -v 'vendor/' | grep -v 'examples/' | grep -v 'old/' | grep -v 'tmp/'`; do diff --git a/test/test-govet.sh b/test/test-govet.sh index debd24b7..c87d6ba4 100755 --- a/test/test-govet.sh +++ b/test/test-govet.sh @@ -4,12 +4,35 @@ . test/util.sh echo running test-govet.sh + +failures='' +function run-test() +{ + $@ || failures=$( [ -n "$failures" ] && echo "$failures\\n$@" || echo "$@" ) +} + ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" # dir! cd "${ROOT}" +function simplify-gocase() { + grep 'case _ = <-' "$1" && fail_test 'case _ = <- can be simplified to: case <-' # this can be simplified +} + +function token-coloncheck() { + grep -Ei "[\/]+[\/]+[ ]*+(FIXME[^:]|TODO[^:]|XXX[^:])" "$1" && fail_test 'Token is missing a colon' # tokens must end with a colon +} + for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -path './tmp/*'`; do - go vet "$file" && echo PASS || fail_test "go vet did not pass" # since it doesn't output an ok message on pass - grep 'log.' "$file" | grep '\\n"' && fail_test 'no \n needed in log.Printf()' || echo PASS # no \n needed in log.Printf() - grep 'case _ = <-' "$file" && fail_test 'case _ = <- can be simplified to: case <-' || echo PASS # this can be simplified - grep -Ei "[\/]+[\/]+[ ]*+(FIXME[^:]|TODO[^:]|XXX[^:])" "$file" && fail_test 'Token is missing a colon' || echo PASS # tokens must end with a colon + run-test go vet "$file" || fail_test "go vet did not pass" # since it doesn't output an ok message on pass + run-test grep 'log.' "$file" | grep '\\n"' && fail_test 'no newline needed in log.Printf()' # no \n needed in log.Printf() + run-test simplify-gocase "$file" + run-test token-coloncheck "$file" done + +if [[ -n "$failures" ]]; then + echo 'FAIL' + echo 'The following tests have failed:' + echo -e "$failures" + exit 1 +fi +echo 'PASS'