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