-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathtest-unit.sh
More file actions
executable file
·46 lines (40 loc) · 1006 Bytes
/
test-unit.sh
File metadata and controls
executable file
·46 lines (40 loc) · 1006 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
#!/usr/bin/env bash
set -e
CHANGE_ONLY="false"
GO_MOD_DIRS=$(find . -type f -name "go.mod" | xargs -n1 dirname)
print_usage() {
echo "Runs unit-tests for all modules."
echo
echo "Syntax: ./test-unit.sh [-c]"
echo "options:"
echo "c Run only on changed modules."
echo "h Print this Help."
echo
}
while getopts 'cp:' flag; do
case "${flag}" in
c) CHANGE_ONLY='true' ;;
*) print_usage
exit 1 ;;
esac
done
echo "Running test-unit with the following options:"
echo "CHANGE_ONLY: $CHANGE_ONLY"
echo $@
for f in $GO_MOD_DIRS; do
if [ -d $f ]; then
cd $f
CHANGES=""
if [ "$CHANGE_ONLY" = "true" ]; then
CHANGES=$(git diff --name-only HEAD..origin/main ../)
if [ "$CHANGES" = "" ]; then
echo "No changes in $f, skipping."
cd -
continue
fi
fi
echo "Running unit tests $f"
go test -race -v ./...
cd -
fi
done