ref: cf5c1d13fb0285416340190aef65207ef0e3dfe5
parent: e1b5f8f8dee7eba58fe610a2b18a7f3bb80c6ede
author: Ori Bernstein <[email protected]>
date: Wed Oct 9 12:20:05 EDT 2013
Extend test framework to support comparing stdout to files
--- a/test/test.sh
+++ b/test/test.sh
@@ -17,6 +17,16 @@
../myrbuild/myrbuild -b $1 -C../6/6m -M../muse/muse -I../libstd $1.myr
}
+function comparedto {
+ if [ "`./$1`" != "`cat "$2"`" ]; then
+ echo "FAIL: $1"
+ FAILED="$FAILED $1"
+ NFAILED=$[$NFAILED + 1]
+ else
+ echo "PASS: $1"
+ fi
+}
+
function prints {
if [ "`./$1`" != "$2" ]; then
echo "FAIL: $1"
@@ -82,6 +92,7 @@
case $type in
E) exitswith $tst $val ;;
P) prints $tst $val ;;
+ C) comparedto $tst $val ;;
esac
done
if [ -z "$NFAILED" ]; then
--- a/test/tests
+++ b/test/tests
@@ -7,9 +7,14 @@
# The test that will run. We will try to
# compile 'testname.myr' to 'testname',
# and then execute it, verifying the result
-# [E|P]: Result type
+# [E|P|C]: Result type
# E tells us that the result is an exit status
-# E tells us that the result output on stdout
+# P tells us that the result is on stdout,
+# and should be compared to the value on the
+# line
+# C tells us that the result is on stdout,
+# and should be compared to the contents of
+# the file passed on the line.
# result: Result value
# What we compare with. This should be self-
# evident.
@@ -86,11 +91,12 @@
B slgrow E 42
B tyrec E 42
B infer-named E 99
-B helloworld P Hello-世界
-B catfile P Hello-世界
-B encodechar P 1世界äa
B exportcycle E 0
B import-type E 0
+B helloworld P Hello-世界
+B encodechar P 1世界äa
+B catfile C data/catfile
+B strtab C data/strtab-out
# B local-labels E 10 ## BUGGERED
F declmismatch
F infermismatch