forked from ocaml/merlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·55 lines (52 loc) · 1.34 KB
/
test.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
if [ "$1" = "--update" ]; then
UPDATE=1
shift 1
else
UPDATE=0
fi
if test -n "$1" ; then
# Use more appropriate jsondiff if available
if [ -n "$DIFF" ]; then
:
elif which jsondiff >& /dev/null; then
DIFF="jsondiff -color"
else
DIFF="diff -u"
fi
out=`mktemp`
while test -n "$1"; do
(cd tests && bash $1.in) | ./ocamlmerlin > $out
if [ -r ./tests/$1.out ]; then
$DIFF ./tests/$1.out $out
else
less $out
fi
if [ "$UPDATE" = 1 ]; then
cp $out ./tests/$1.out
fi
shift 1
done
rm $out
else
for file in tests/*.in; do
test_nb=`basename $file .in`
temp_out=`mktemp`
real_out=`echo "$file"|sed 's/\.in$/.out/'`
(cd tests && bash $test_nb.in) | ./ocamlmerlin > $temp_out
if [ "$UPDATE" = 1 ]; then
echo "############## $test_nb ##############"
diff $temp_out $real_out
mv $temp_out $real_out
else
diff $temp_out $real_out > /dev/null
if [[ $? != 0 ]] ; then
echo -e "$test_nb: \e[1;31mFAILED\e[0m"
echo " run ./test.sh $test_nb to have more informations"
else
echo -e "$test_nb: \e[1;32mOK\e[0m"
fi
rm $temp_out
fi
done
fi