-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·54 lines (43 loc) · 1.17 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# shellcheck disable=SC2059
main() {
Files=$(find . -name '*test.gr')
printerr "\x1b[36m\nRunning tests in *.test.gr files\x1b[0m\n"
echo "$Files"
./clean.sh
Passed=0
Failed=0
for f in $Files; do
test "$f"
done
# test "./test.gr"
echo
echo
if [ "$Failed" = 0 ]; then
printerr "\x1b[32m=============================\x1b[0m\n"
printerr " ✅ \x1b[32mAll %s test files passed.\x1b[0m\n" "$Passed"
printerr "\x1b[32m=============================\x1b[0m\n"
./clean.sh
exit 0
else
printerr "\x1b[31m=========================\x1b[0m\n"
printerr " ✅ \x1b[32m%s test files passed.\x1b[0m\n" "$Passed"
printerr " ❌ \x1b[41m%s test files failed.\x1b[0m\n" "$Failed"
printerr "\x1b[31m=========================\x1b[0m\n"
./clean.sh
exit 1
fi
}
test() {
printerr "\x1b[36m\n$ grain %s\x1b[0m" "$1"
if ! grain "$1"; then
printerr "\n❌ \x1b[41mTests in %s failed.\x1b[0m\n" "$1"
Failed=$(("$Failed" + 1))
else
printerr "\n✅ \x1b[42mTests in %s passed.\x1b[0m\n" "$1"
Passed=$(("$Passed" + 1))
fi
}
echoerr() { printf "\n%s" "$*" >&2; }
printerr() { printf "$1" "$2" >&2; }
main