test 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash -e
  2. #
  3. # Run all etcd tests
  4. # ./test
  5. # ./test -v
  6. #
  7. # Run tests for one package
  8. #
  9. # PKG=./wal ./test
  10. # PKG=snap ./test
  11. # Invoke ./cover for HTML output
  12. COVER=${COVER:-"-cover"}
  13. source ./build
  14. TESTABLE="etcdserver etcdserver/etcdhttp etcdserver/etcdserverpb functional proxy raft snap store wait wal"
  15. FORMATTABLE="$TESTABLE cors.go main.go"
  16. # user has not provided PKG override
  17. if [ -z "$PKG" ]; then
  18. TEST=$TESTABLE
  19. FMT=$FORMATTABLE
  20. # user has provided PKG override
  21. else
  22. # strip out leading dotslashes and trailing slashes from PKG=./foo/
  23. TEST=${PKG/#./}
  24. TEST=${TEST/#\//}
  25. TEST=${TEST/%\//}
  26. # only run gofmt on packages provided by user
  27. FMT="$TEST"
  28. fi
  29. # split TEST into an array and prepend REPO_PATH to each local package
  30. split=(${TEST// / })
  31. TEST=${split[@]/#/${REPO_PATH}/}
  32. echo "Running tests..."
  33. go test ${COVER} $@ ${TEST} --race
  34. echo "Checking gofmt..."
  35. fmtRes=$(gofmt -l $FMT)
  36. if [ -n "${fmtRes}" ]; then
  37. echo -e "gofmt checking failed:\n${fmtRes}"
  38. exit 255
  39. fi
  40. echo "Success"