tester.sh 738 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. COVER="coverage"
  3. OUT="out"
  4. HTML="html"
  5. folders=$(find src/** -maxdepth 1 -type d)
  6. [ ! -e "$COVER" ] && mkdir "$COVER"
  7. [ ! -e "$COVER"/"$OUT" ] && mkdir "$COVER"/"$OUT"
  8. [ ! -e "$COVER"/"$HTML" ] && mkdir "$COVER"/"$HTML"
  9. go test ./src -coverprofile="$COVER"/"$OUT"/src.out
  10. go tool cover -html="$COVER"/"$OUT"/src.out -o "$COVER"/"$HTML"/src.html
  11. for folder in $folders; do
  12. name=$(echo "$folder" | sed -e "s/\///g")
  13. go test ./"$folder" -coverprofile="$COVER"/"$OUT"/"$name".out
  14. if [ -f "$COVER"/"$OUT"/"$name".out ]; then
  15. lines=$(wc -l "$COVER"/"$OUT"/"$name".out | cut -d ' ' -f1)
  16. [ "$lines" -gt 1 ] && go tool cover -html="$COVER"/"$OUT"/"$name".out -o "$COVER"/"$HTML"/"$name".html
  17. fi
  18. done