-
-
Notifications
You must be signed in to change notification settings - Fork 965
/
tests.sh
executable file
·70 lines (57 loc) · 1.87 KB
/
tests.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env zsh
# Required for shunit2 to run correctly
setopt shwordsplit
# ------------------------------------------------------------------------------
# Colors
# Set color variables for colorful output
# ------------------------------------------------------------------------------
# If we have tput, let's set colors
if [[ ! -z $(which tput 2> /dev/null) ]]; then
reset=$(tput sgr0)
bold=$(tput bold)
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
magenta=$(tput setaf 5)
cyan=$(tput setaf 6)
fi
# ------------------------------------------------------------------------------
# VARIABLES
# Paths to important resources
# ------------------------------------------------------------------------------
TESTS="$(find . -type f -name "*.test.zsh")"
EXIT_CODE=0
# ------------------------------------------------------------------------------
# HELPERS
# Useful functions for common tasks
# ------------------------------------------------------------------------------
header() {
[[ -n $2 ]] && color=$1 || color=$cyan
[[ -n $2 ]] && content=${@:2} || content=$@
echo $color$bold
echo '--------------------------------------------------------------------------------'
echo "$content"
echo '--------------------------------------------------------------------------------'
echo $reset
}
# ------------------------------------------------------------------------------
# MAIN
# Checkings and installing process
# ------------------------------------------------------------------------------
main() {
for test in $TESTS; do
header "Run $test..."
( eval zsh $test 2>&1 )
local exitcode="$?"
[ "$exitcode" != "0" ] && EXIT_CODE=$exitcode
done
if [ "$EXIT_CODE" != "0" ]; then
header $red "Tests are failing!"
exit $EXIT_CODE
else
header $green "Tests are passing!"
exit 0
fi
}
main "$@"