test 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash -e
  2. #
  3. # Run all flannel tests (not including functional)
  4. # ./test
  5. # ./test -v
  6. #
  7. # Run tests for one package
  8. # PKG=./unit ./test
  9. # PKG=ssh ./test
  10. #
  11. # Invoke ./cover for HTML output
  12. COVER=${COVER:-"-cover"}
  13. source ./build
  14. TESTABLE="pkg/ip subnet remote"
  15. FORMATTABLE="$TESTABLE"
  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 slashes and dots from PKG=./foo/
  23. TEST=${PKG//\//}
  24. TEST=${TEST//./}
  25. # only run gofmt on packages provided by user
  26. FMT="$TEST"
  27. fi
  28. # split TEST into an array and prepend REPO_PATH to each local package
  29. split=(${TEST// / })
  30. TEST=${split[@]/#/${REPO_PATH}/}
  31. echo "Running tests..."
  32. go test -i ${TEST}
  33. go test ${COVER} $@ ${TEST}
  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"