-
Notifications
You must be signed in to change notification settings - Fork 76
/
run-tests.sh
executable file
·64 lines (55 loc) · 1.31 KB
/
run-tests.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
56
57
58
59
60
61
62
63
#!/bin/sh
# How to use this test script:
# Put all of your tests into a directory like "tests/scanner".
# Name the good tests goodXX.bminor and the bad tests badXX.bminor.
# Then use run-tests.sh and give the location of the compiler
# executable, the command-line option, and the test directory.
# This script will run all of the tests, and show you the
# details of which ones failed.
# For example:
# run-tests.sh $HOME/mycompiler/bminor -scan tests/scanner
if [ $# -ne 3 ]
then
echo "Usage: $0 <compiler> <mode> <test-dir>"
exit 1
fi
COMPILER=$1
MODE=$2
TESTDIR=$3
LINES=-------------------------------------------
for testfile in ${TESTDIR}/good*.bminor
do
if ${COMPILER} ${MODE} $testfile > $testfile.out 2>&1
then
echo "$testfile success (as expected)"
else
echo "$testfile failure (INCORRECT)"
echo ${LINES}
echo Test Input:
echo ${LINES}
cat $testfile
echo ${LINES}
echo Your Output:
echo ${LINES}
cat $testfile.out
echo ${LINES}
fi
done
for testfile in ${TESTDIR}/bad*.bminor
do
if ${COMPILER} ${MODE} $testfile > $testfile.out 2>&1
then
echo "$testfile success (INCORRECT)"
echo ${LINES}
echo Test Input:
echo ${LINES}
cat $testfile
echo ${LINES}
echo Your Output:
echo ${LINES}
cat $testfile.out
echo ${LINES}
else
echo "$testfile failure (as expected)"
fi
done