forked from containernetworking/cni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·34 lines (29 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
#!/usr/bin/env bash
set -euo pipefail
# switch into the repo root directory
cd "$(dirname $0)"
PKGS=${PKGS:-$(go list ./... | xargs echo)}
echo -n "Running tests "
if [ ! -z "${COVERALLS:-""}" ]; then
# coverage profile only works per-package
echo "with coverage profile generation..."
i=0
for t in ${PKGS}; do
go test -covermode set -coverprofile ${i}.coverprofile "${t}"
i=$((i+1))
done
else
echo "without coverage profile generation..."
go test ${PKGS}
fi
echo "Checking license header..."
licRes=$(
for file in $(find . -type f -iname '*.go'); do
head -n1 "${file}" | grep -Eq "(Copyright|generated)" || echo -e " ${file}"
done
)
if [ -n "${licRes}" ]; then
echo -e "license header checking failed:\n${licRes}"
exit 255
fi
echo "Success"