forked from 3ximus/link-cut
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·30 lines (25 loc) · 812 Bytes
/
run_tests.sh
File metadata and controls
executable file
·30 lines (25 loc) · 812 Bytes
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
#!/bin/bash
make --quiet || exit 1
hash colordiff 2>/dev/null && DIFF=colordiff || DIFF=diff
for in in ${@:-tests/*.txt} ; do
[[ ! -e $in ]] && echo -e "\e[31mUnexistent test file $in\e[0m" && exit 1
tst="${in##*/}"
out="tests/${tst}.out"
echo -en "\e[1;38;5;215mRunning $in \e[0m > $out "
./project <$in >$out
output=$(diff -q $out "tests/expected-output/$tst")
if [[ $output ]]; then
echo -e "[ \e[1;38;5;196mFailed\e[0m ]"
echo -e " \e[1mTest Expected\e[0m"
$DIFF -y <(nl $out) <(nl "tests/expected-output/$tst")
else
echo -e "[ \e[1;38;5;41mSucceded\e[0m ]"
fi
[[ -e time.log ]] && \
echo -e "\t\e[1mTimes:" && \
cat time.log && \
echo -e "\e[0m"
done
make --quiet clean
rm tests/*.out
[[ -e time.log ]] && rm time.log