test.sh 692 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Script that runs tests, code coverage, and benchmarks all at once.
  3. # Builds a symlink in /tmp, mostly to avoid messing with GOPATH at the user's shell level.
  4. TEMPORARY_PATH="/tmp/govaluate_test"
  5. SRC_PATH="${TEMPORARY_PATH}/src"
  6. FULL_PATH="${TEMPORARY_PATH}/src/govaluate"
  7. # set up temporary directory
  8. rm -rf "${FULL_PATH}"
  9. mkdir -p "${SRC_PATH}"
  10. ln -s $(pwd) "${FULL_PATH}"
  11. export GOPATH="${TEMPORARY_PATH}"
  12. pushd "${TEMPORARY_PATH}/src/govaluate"
  13. # run the actual tests.
  14. export GOVALUATE_TORTURE_TEST="true"
  15. go test -bench=. -benchmem -coverprofile coverage.out
  16. status=$?
  17. if [ "${status}" != 0 ];
  18. then
  19. exit $status
  20. fi
  21. # coverage
  22. go tool cover -func=coverage.out
  23. popd