Debian Codegraph @

test.sh

raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 # switch into the repo root directory
5 cd "$(dirname $0)"
6
7 PKGS=${PKGS:-$(go list ./... | xargs echo)}
8
9 echo -n "Running tests "
10 if [ ! -z "${COVERALLS:-""}" ]; then
11 # coverage profile only works per-package
12 echo "with coverage profile generation..."
13 i=0
14 for t in ${PKGS}; do
15 go test -covermode set -coverprofile ${i}.coverprofile "${t}"
16 i=$((i+1))
17 done
18 else
19 echo "without coverage profile generation..."
20 go test ${PKGS}
21 fi
22
23 echo "Checking license header..."
24 licRes=$(
25 for file in $(find . -type f -iname '*.go'); do
26 head -n1 "${file}" | grep -Eq "(Copyright|generated)" || echo -e " ${file}"
27 done
28 )
29 if [ -n "${licRes}" ]; then
30 echo -e "license header checking failed:\n${licRes}"
31 exit 255
32 fi
33
34 echo "Success"