test.bash 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Copyright 2018 The Go Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style
  4. # license that can be found in the LICENSE file.
  5. cd "$(git rev-parse --show-toplevel)"
  6. BOLD="\x1b[1mRunning: "
  7. PASS="\x1b[32mPASS"
  8. FAIL="\x1b[31mFAIL"
  9. RESET="\x1b[0m"
  10. echo -e "${BOLD}go test -tags protolegacy ./...${RESET}"
  11. RET_TEST0=$(go test -tags protolegacy ./... | egrep -v "^(ok|[?])\s+")
  12. if [[ ! -z "$RET_TEST0" ]]; then echo "$RET_TEST0"; echo; fi
  13. echo -e "${BOLD}go test -tags use_golang_protobuf_v1 ./...${RESET}"
  14. RET_TEST1=$(go test -tags use_golang_protobuf_v1 ./... | egrep -v "^(ok|[?])\s+")
  15. if [[ ! -z "$RET_TEST1" ]]; then echo "$RET_TEST1"; echo; fi
  16. echo -e "${BOLD}go test -tags "use_golang_protobuf_v1 purego" ./...${RESET}"
  17. RET_TEST2=$(go test -tags "use_golang_protobuf_v1 purego" ./... | egrep -v "^(ok|[?])\s+")
  18. if [[ ! -z "$RET_TEST2" ]]; then echo "$RET_TEST2"; echo; fi
  19. echo -e "${BOLD}go generate${RESET}"
  20. RET_GEN=$(go run ./internal/cmd/generate-alias 2>&1)
  21. if [[ ! -z "$RET_GEN" ]]; then echo "$RET_GEN"; echo; fi
  22. echo -e "${BOLD}go fmt${RESET}"
  23. RET_FMT=$(gofmt -d $(git ls-files *.go) 2>&1)
  24. if [[ ! -z "$RET_FMT" ]]; then echo "$RET_FMT"; echo; fi
  25. echo -e "${BOLD}git diff${RESET}"
  26. RET_DIFF=$(git diff --no-prefix HEAD 2>&1)
  27. if [[ ! -z "$RET_DIFF" ]]; then echo "$RET_DIFF"; echo; fi
  28. echo -e "${BOLD}git ls-files${RESET}"
  29. RET_FILES=$(git ls-files --others --exclude-standard 2>&1)
  30. if [[ ! -z "$RET_FILES" ]]; then echo "$RET_FILES"; echo; fi
  31. if [[ ! -z "$RET_TEST0" ]] || [[ ! -z "$RET_TEST1" ]] || [[ ! -z "$RET_TEST2" ]] || [[ ! -z "$RET_GEN" ]] || [ ! -z "$RET_FMT" ] || [[ ! -z "$RET_DIFF" ]] || [[ ! -z "$RET_FILES" ]]; then
  32. echo -e "${FAIL}${RESET}"; exit 1
  33. else
  34. echo -e "${PASS}${RESET}"; exit 0
  35. fi