-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.bash
executable file
·114 lines (90 loc) · 2.34 KB
/
run_tests.bash
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
TEST_DIR=./test-files
TMP_FILE=$TEST_DIR/.tmp
TEST_PREFIX=test_
RESULT_PREFIX=result_
SUCCESSFUL_TESTS=""
FAILED_TESTS=""
UNCHECKED_TESTS=""
VERBOSE=0
VERBOSE_DIFF=0
usage() {
printf "Usage $0 [-dv]\n" 1>&2
printf "\td - Output diff of result and expected result on test failure\n"
printf "\tv - Output result and expected result on test failue\n"
exit 1
}
while getopts "dv" o; do
case "${o}" in
d)
VERBOSE_DIFF=1
;;
v)
VERBOSE=1
;;
*)
usage
;;
esac
done
for F in `find $TEST_DIR -type f -name test_'*' | sort`
do
echo "-----------------------------------------------------------"
echo "Running test file: $F"
./buddy -i $F > $TMP_FILE
RESULT_FILE=`echo $F | sed "s/$TEST_PREFIX/$RESULT_PREFIX/g"`
echo "Expected result file: $RESULT_FILE"
if [ -e "$RESULT_FILE" ]; then
DIFF_OUT=`diff -w $TMP_FILE $RESULT_FILE`
if [ "$DIFF_OUT" != "" ]; then
echo "Output from test $F differs"
FAILED_TESTS+=" $F"
if [ "$VERBOSE" != "1" ] && [ "$VERBOSE_DIFF" != "1" ]; then
echo "Please specify the -v or -d options for further details about failure. Re-run with \"$0 -h\" for usage information."
fi
echo ""
if [ "$VERBOSE_DIFF" -eq "1" ]; then
echo "*** DIFFERENCE: < Test Result; > Expected Result ***"
echo "$DIFF_OUT"
echo ""
fi
if [ "$VERBOSE" -eq "1" ]; then
echo "*** Test output ***"
cat $TMP_FILE
echo "*** Expected output ***"
cat $RESULT_FILE
echo ""
fi
else
echo "Test passed"
SUCCESSFUL_TESTS+=" $F"
echo ""
fi
else
echo "No result file for test: $F... Skipping diff"
UNCHECKED_TESTS+=" $F"
echo "OUTPUT:"
cat $TMP_FILE
echo ""
fi
done
rm $TMP_FILE
echo "======================= SUMMARY ========================="
echo "SUCCESSFUL TESTS"
for F in $SUCCESSFUL_TESTS
do
echo $F
done
echo ""
echo "FAILED TESTS"
for F in $FAILED_TESTS
do
echo $F
done
echo ""
echo "UNCHECKED TESTS"
for F in $UNCHECKED_TESTS
do
echo $F
done
echo ""