aboutsummaryrefslogtreecommitdiff
path: root/tests/common.sh
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-01 03:22:10 -0500
committerMustafa Quraish <[email protected]>2022-02-01 03:22:10 -0500
commit7aab3bded245de89a8bab23847f074e3b2572c5a (patch)
treeab915eae99832d1717edecc228825eaf7c849c8a /tests/common.sh
parentGlobal variables now supported! + some fixes to OP_ASSIGN (diff)
downloadcup-7aab3bded245de89a8bab23847f074e3b2572c5a.tar.xz
cup-7aab3bded245de89a8bab23847f074e3b2572c5a.zip
Testing: Add support for testing stdout results, check builtins
Diffstat (limited to 'tests/common.sh')
-rw-r--r--tests/common.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/common.sh b/tests/common.sh
index 575443c..1047708 100644
--- a/tests/common.sh
+++ b/tests/common.sh
@@ -41,4 +41,39 @@ function assert_compile_failure_stdin() {
exit 1
fi
echo -n "."
+}
+
+function assert_stdout_text() {
+ build/cupcc -c "$1" -o build/test.nasm
+ make build/test.out -s
+
+ set +e
+ output=$(build/test.out)
+ res=$?
+ set -e
+ if [ $res -ne 0 ]
+ then
+ echo ""
+ echo "----------------------------------------------"
+ echo "Test failed: executable returned non-0 code"
+ echo "----------------------------------------------"
+ echo "$code"
+ exit 1
+ fi
+ if [[ "$output" != $2 ]]
+ then
+ echo ""
+ echo "----------------------------------------------"
+ echo "Test failed: Did not get expected output"
+ echo "----------------------------------------------"
+ echo "$code"
+ echo "----------------------------------------------"
+ echo "Expected:"
+ echo "$2"
+ echo "----------------------------------------------"
+ echo "Got:"
+ echo "$output"
+ exit 1
+ fi
+ echo -n "."
} \ No newline at end of file