test.sh 835 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. set -e
  3. GOMAXPROCS=1 go test -timeout 90s ./...
  4. if [ "$GOARCH" = "amd64" ] || [ "$GOARCH" = "arm64" ]; then
  5. # go test: -race is only supported on linux/amd64, linux/ppc64le,
  6. # linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
  7. GOMAXPROCS=4 go test -timeout 90s -race ./...
  8. fi
  9. # no tests, but a build is something
  10. for dir in apps/*/ bench/*/; do
  11. dir=${dir%/}
  12. if grep -q '^package main$' $dir/*.go 2>/dev/null; then
  13. echo "building $dir"
  14. go build -o $dir/$(basename $dir) ./$dir
  15. else
  16. echo "(skipped $dir)"
  17. fi
  18. done
  19. # disable "composite literal uses unkeyed fields"
  20. go vet -composites=false ./...
  21. FMTDIFF="$(find apps internal nsqd nsqlookupd -name '*.go' -exec gofmt -d '{}' ';')"
  22. if [ -n "$FMTDIFF" ]; then
  23. printf '%s\n' "$FMTDIFF"
  24. exit 1
  25. fi