-
Notifications
You must be signed in to change notification settings - Fork 15
/
all.sh
executable file
·36 lines (26 loc) · 934 Bytes
/
all.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
#!/usr/bin/env bash
# Tests Go projects. There must be project cmd sub directories where this script is executed.
# Assumes a flat directory hierarchy below cmd (the maxdepth in the find command).
# Runs go test for each cmd sub directory. This will check the code compiles even when there are
# no test files.
# If there is an env.list file in the sub project then this will be used to set env var before running
# go test and unset them after. This avoids accidental cross project dependencies from env.list files.
#
# usage: ./all.sh
set -e
if [ ! -f all.sh ]; then
echo 'all.sh must be run from the project root' 1>&2
exit 1
fi
projects=`ls cmd`
function runTests {
if [ -f ${1}/env.list ]; then
export $(cat ${1}/env.list | grep = | xargs)
fi
go test -v ./${1}
return $?
}
for i in ${projects[@]}; do
# run tests in a subshell so they can freely modify their environment variables
(runTests cmd/${i})
done