blob: ddff74ff0badb3f90fed89c5a07471b07af35c79 (
plain)
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/sh
if [ -z "$FORTH_CMD" ] ; then
FORTH_CMD="./forth"
fi
n=0
failed=0
runtest () {
file="$1"
output="$(mktemp)"
expectedoutput="$(mktemp)"
sed '0,/^INPUT$/d;/^OUTPUT$/,$d' "$file" | "$FORTH_CMD" > "$output" &2> /dev/null
sed '0,/^OUTPUT$/d' "$file" > "$expectedoutput"
diff="$(diff -w -y "$output" "$expectedoutput")"
if [ "1" -eq "$?" ] ; then
echo "Test $n failed: $file" >&2
echo "Diff:" >&2
echo "$diff"
exitcode=1
failed="$(expr "$failed" + 1)"
fi
}
for f in ./tests/*; do
n="$(expr "$n" + 1)"
runtest "$f"
done
if [ "0" -eq "$failed" ]; then
echo "All $n tests passed" >&2
exit 0
else
echo "$failed/$n tests failed" >&2
fi
|