-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·40 lines (30 loc) · 835 Bytes
/
test.sh
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
39
40
#!/usr/bin/env bash
unset LOG_LEVEL
set -uo pipefail
while IFS=\= read -r dir; do
dirs+=("$dir")
done < <(find . -type d -not -path "./.git*")
# readarray -t dirs < <(find . -type d -not -path "./.git*")
run_tests() {
local dir=$1
echo "Testing $dir"
(
cd "$dir" || exit 1
out=$(go test -cover -coverprofile=coverage.out 2>&1)
code=$?
if [ $code -ne 0 ]; then
if echo "$out"| grep -q "files in"; then
code=0
else
echo "Error testing $dir"
echo "$out"
exit $code
fi
fi
)
}
for dir in "${dirs[@]}"; do
run_tests "$dir"
done
"$HOME/go/bin/gocovmerge" "$(find . -name 'coverage*.out')" > merged_coverage.out
go tool cover -func=merged_coverage.out > coverage.txt