-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
executable file
·59 lines (52 loc) · 1.32 KB
/
test
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
#!/bin/bash -e
C_RED=$'\e[31m'
C_GREEN=$'\e[32m'
C_YELLOW=$'\e[33m'
C_BLUE=$'\e[34m'
C_NONE=$'\e[39m'
VERBOSE='0'
if [ "$1" = '-v' ]; then
VERBOSE='1'
shift
fi
count='0'
passed='0'
failed='0'
function RunTest {
((count++)) || true
result='0'
if [ "${VERBOSE}" -eq '1' ]; then
echo -e "[${C_BLUE}TEST${C_NONE}] $1"
fi
output=$(env -i bash -c "
function ALIAS { local list=\$( alias | tr '\n' '|' | sed 's/.$//'); echo \"alias={\${list}}\" > /dev/stderr; echo \"\${list}\"; }
function MKALIAS { local list=\$(mkalias | tr '\n' '|' | sed 's/.$//'); echo \"mkalias={\${list}}\" > /dev/stderr; echo \"\${list}\"; }
source ../mkalias.sh
source '$1'
" 2>&1) || result="$?"
if [ "${VERBOSE}" -eq '1' ]; then
echo "${output}"
echo -e "[${C_BLUE}EXIT${C_NONE}] $result"
fi
if [ "${result}" -eq '0' ]; then
((passed++)) || true
echo -n "[${C_GREEN}PASS${C_NONE}]"
else
((failed++)) || true
echo -n "[${C_RED}FAIL${C_NONE}]"
fi
echo " $1"
}
cd tests
if [ -z "$1" ]; then
for t in $(ls -1 | LANG=C sort); do
RunTest "${t}"
done
else
while [ -n "$1" ]; do
RunTest "$1"
shift
done
fi
echo "${count} TESTS: ${passed} PASSED, ${failed} FAILED"
[ "${failed}" -eq '0' ]