-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·70 lines (54 loc) · 1016 Bytes
/
test.sh
File metadata and controls
executable file
·70 lines (54 loc) · 1016 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -euo pipefail
COVERAGE_DIR=.test_coverage
function clean() {
echo "Clean up"
rm -rf $COVERAGE_DIR
}
function prepare() {
mkdir -p $COVERAGE_DIR
echo "Run tests"
go test ./... -coverprofile $COVERAGE_DIR/coverage.out -covermode count
}
function html() {
echo "Create Coverage HTML"
go tool cover -html=$COVERAGE_DIR/coverage.out -o $COVERAGE_DIR/test-coverage.html
}
function coverage() {
echo "Show Coverage"
go tool cover -func=$COVERAGE_DIR/coverage.out
}
function task_clean() {
clean
}
function task_html() {
clean
prepare
html
}
function task_default() {
clean
prepare
coverage
}
function task_usage() {
cat <<HEREDOC
usage: $0 <command>
Available commands:
clean
Cleans the coverage directory
html
Test + HTML Report
coverage
Test + Coverage
HEREDOC
exit 1
}
cmd="${1:-}"
shift || true
case "$cmd" in
clean) task_clean "$@";;
html) task_html "$@";;
coverage) task_default ;;
*) task_usage ;;
esac