forked from schlomo/automirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.sh
executable file
·40 lines (36 loc) · 1018 Bytes
/
runtests.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
#!/bin/bash
#
set -e -E -u
function do_test {
local xrandr_output="$1" ; shift
local script_output="$1" ; shift
res="$( XRANDR_STATUS_PROGRAM="cat $xrandr_output" XRANDR_SET_PROGRAM=echo AUTOMIRROR_NOTIFY_COMMAND=: ./automirror.sh)"
if [[ "$res" == "$(< $script_output)" ]] ; then
return 0
else
echo "Difference:"
diff -u --label EXPECTED_RESULT --label ACTUAL_RESULT -- $script_output - <<<"$res"
return 1
fi
}
failed=0
for test_case in testdata/*.txt ; do
[[ "$test_case" == *result.txt ]] && continue
script_output=${test_case%.txt}_result.txt
if [[ "$script_output" && -r "$script_output" ]] ; then
if do_test "$test_case" "$script_output" ; then
echo "OK $test_case"
else
let failed++ 1
echo "FAILED $test_case"
fi
else
echo "Missing test result file '$script_output'"
fi
done
if (( failed == 0 )) ; then
exit 0
else
echo $failed TESTS FAILED
exit 1
fi