1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env bash
set -exuo pipefail
# Parse options.
output_cover_profile="/dev/null"
while getopts "c:" opt; do
case "${opt}" in
c) output_cover_profile="${OPTARG}" ;;
esac
done
# Packages with stress test mode.
pkgs=(
"alg"
"alg/contfrac"
"alg/dict"
"alg/ensemble"
"alg/heuristic"
"acc"
)
# Test each package individually. This is required since custom test arguments
# do not work when calling "go test" on multiple packages.
cover_profiles=()
for pkg in "${pkgs[@]}"; do
pushd "${pkg}"
cover_profile=$(mktemp)
go test -stress -timeout=0 -coverprofile="${cover_profile}" -covermode=set
cover_profiles+=("${cover_profile}")
popd
done
# Merge profiles.
covertool merge --output "${output_cover_profile}" "${cover_profiles[@]}"
# Clean up.
rm -rf "${cover_profiles[@]}"
|