cov.sh 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh -l
  2. PATH=$PATH
  3. BIN_PATH="$(swift build --show-bin-path)"
  4. XCTEST_PATH="$(find ${BIN_PATH} -name '*.xctest')"
  5. COV_BIN=$XCTEST_PATH
  6. INSTR_PROFILE=.build/debug/codecov/default.profdata
  7. IGNORE_FILENAME_REGEX=".build|Tests"
  8. FORMAT="lcov"
  9. OUTPUT_FILE=.build/debug/codecov/lcov.info
  10. while :; do
  11. case $1 in
  12. -f|--format) FORMAT=$2
  13. shift
  14. ;;
  15. -o|--output) OUTPUT_FILE=$2
  16. shift
  17. ;;
  18. *) break
  19. esac
  20. shift
  21. done
  22. if [[ "$OSTYPE" == "darwin"* ]]; then
  23. f="$(basename $XCTEST_PATH .xctest)"
  24. COV_BIN="${COV_BIN}/Contents/MacOS/$f"
  25. PATH="/usr/local/opt/llvm/bin:$PATH"​
  26. fi
  27. mkdir -p "$(dirname "$OUTPUT_FILE")"
  28. llvm-cov report \
  29. "${COV_BIN}" \
  30. -instr-profile=$INSTR_PROFILE \
  31. -ignore-filename-regex=$IGNORE_FILENAME_REGEX \
  32. -use-color
  33. llvm-cov export \
  34. "${COV_BIN}" \
  35. -instr-profile=$INSTR_PROFILE \
  36. -ignore-filename-regex=$IGNORE_FILENAME_REGEX \
  37. -format=$FORMAT > $OUTPUT_FILE