summaryrefslogtreecommitdiff
path: root/tests/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.sh')
-rwxr-xr-xtests/test.sh33
1 files changed, 19 insertions, 14 deletions
diff --git a/tests/test.sh b/tests/test.sh
index b0ee8e6..0b10981 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
DIR=$(dirname $0)
TOC=$DIR/../toc
CFLAGS="-g -Wno-parentheses-equality"
@@ -12,18 +12,23 @@ compile() {
$CC $EXTRA_CFLAGS $CFLAGS -o $DIR/$1/$1.bin $DIR/$1/$1.c || exit 1
}
-STARTPWD="$(pwd)"
-
-valgrind -q $TOC $DIR/bf/bf.toc -o $DIR/bf/bf.c > /dev/null || exit 1
-for CC in $COMPILERS; do
+do_tests() {
+ valgrind -q $TOC "$DIR/$1/$1.toc" -o "$DIR/$1/$1.c" > /dev/null || exit 1
+ for CC in $COMPILERS; do
- for EXTRA_CFLAGS in "-O0 -g" "-O3 -s"; do
- echo "Running tests with C compiler $CC and flags $EXTRA_CFLAGS."
- printf "bf... "
- compile bf
- cd $DIR/bf
- ./test.sh || exit 1
- echo "passed!"
- cd $STARTPWD
+ for EXTRA_CFLAGS in "-O0 -g" "-O3 -s"; do
+ printf "Running test $1 C compiler $CC and flags $EXTRA_CFLAGS... "
+ compile "$1"
+ cd "$DIR/$1"
+ ./test.sh || { printf "\x1b[91mfailed!\x1b[0m\n"; exit 1; }
+ printf '\x1b[92mpassed!\x1b[0m\n'
+ cd $STARTPWD
+ done
done
-done
+
+}
+
+STARTPWD="$(pwd)"
+
+do_tests bf
+do_tests arr