check_coverage.sh (778B)
1 #!/usr/bin/env bash 2 # File : check_coverage.sh 3 # Description: Coverage wrapper around test suite driver script 4 # Copyright 2022 Harvard University. All Rights Reserved. 5 set -e 6 7 tool='coverage' 8 if [[ $# -gt 0 ]]; then 9 # optional argument to use different tool to check coverage 10 tool="${1}"; shift 11 fi 12 13 if [[ ${tool} == 'coverage' ]]; then 14 # run the tests (generates coverage data to build report) 15 ./run_tests.sh coverage run --source=cs107_package "${@}" 16 17 # build the coverage report on stdout 18 coverage report -m 19 elif [[ ${tool} == 'pytest' ]]; then 20 # generate coverage reports with pytest in one go 21 ./run_tests.sh pytest --cov=cs107_package "${@}" 22 else 23 # error: write to stderr 24 >&2 echo "Error: unknown tool '${tool}'" 25 exit 1 26 fi