cover 480 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash -e
  2. #
  3. # Generate coverage HTML for a package
  4. # e.g. PKG=./initialize ./cover
  5. #
  6. if [ -z "$PKG" ]; then
  7. echo "cover only works with a single package, sorry"
  8. exit 255
  9. fi
  10. COVEROUT="coverage"
  11. if ! [ -d "$COVEROUT" ]; then
  12. mkdir "$COVEROUT"
  13. fi
  14. # strip out slashes and dots
  15. COVERPKG=${PKG//\//}
  16. COVERPKG=${COVERPKG//./}
  17. # generate arg for "go test"
  18. export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out"
  19. source test
  20. go tool cover -html=${COVEROUT}/${COVERPKG}.out