-
Notifications
You must be signed in to change notification settings - Fork 16
/
test-runner
executable file
·73 lines (65 loc) · 1.47 KB
/
test-runner
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
70
71
72
73
#!/bin/bash
declare -a priority_desc
priority_desc=([$Critical]='(Critical)' \
[$Important]='(Important)' \
[$Exhaustive]='')
has_subtests=""
begin-subtests () {
[ -n "$DETAIL" ] && echo
}
subtest () {
if [ -n "$DETAIL" ]; then
has_subtests="1"
test_desc="${priority_desc[$test_priority]}"
printf " Sub-test: %${printWidth}s ... " "$1"
if [ "$2" = "0" ]; then
echo "ok $test_desc"
else
echo "FAIL $test_desc"
fi
fi
}
alltrue () {
while [ -n "$1" ]; do
[ "$1" = "0" ] || return 1
shift
done
return 0
}
source $1
shift
case $1 in
create)
$1 $2
;;
clean)
cd $2
clean
;;
compare|verify)
activity=$2
testname=$3
src=$4
dst=$5
max_priority=`max_priority`
test_priority=$max_priority
max_desc=${priority_desc[$max_priority]}
if (( $max_priority <= $run_priority )); then
printf "%s: %${printWidth}s ... " "$activity" "$testname"
$1 $src $dst
x=$?
# Only print the final status if there weren't subtests
if [ ! "$has_subtests" ]; then
if [ "$x" = "0" ]; then
echo "ok $max_desc"
else
echo "FAIL $max_desc"
fi
fi
fi
;;
*)
echo "Ops: create, verify, clean, compare"
exit 1
;;
esac