-
Notifications
You must be signed in to change notification settings - Fork 909
/
test-all.sh
executable file
·53 lines (45 loc) · 1.06 KB
/
test-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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# shellcheck disable=SC1091
GREEN='\033[0;32m'
RED='\033[0;31m'
RC='\033[0m' # Reset Color
basedir=$(git rev-parse --show-toplevel)
usage() {
echo "Run $0 to test all kata setup.sh scripts"
echo "Override shell to test in with e.g. $0 -s zsh"
exit 0
}
RUNSHELL=bash
while getopts s:h option; do
case "${option}"
in
s) RUNSHELL=${OPTARG};;
h) usage;;
*) usage;;
esac
done
echo "Testing all kata setup scripts"
function test-setup (){
return_code=0
failed=0
total=0
scripts=$(find . -name "setup.sh" -type f -print | sort)
for script in ${scripts}; do
((total++))
cd "$(dirname "${script}")" || exit
$RUNSHELL ../utils/test/test_setup.sh setup.sh 2>&1
exit_code=$?
if [ ${exit_code} -ne 0 ]; then
return_code=${exit_code}
((failed++))
fi
cd "$basedir" || exit
done
if [ ${return_code} -ne 0 ]; then
echo -e "${RED}Failed $failed${RC} of $total tests."
else
echo -e "All $total tests completed ${GREEN}successfully.${RC}"
fi
return $return_code
}
test-setup