aboutsummaryrefslogtreecommitdiffstats
path: root/test_compiler.sh
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-02 23:22:51 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-02 23:22:51 +0000
commit446c2394ec8970198d645bbbb462c67b9e3f1b1e (patch)
treefc85d32c2b68efa80910d0a4ce4c1bed78ec4717 /test_compiler.sh
parent34d69709e621b9609833a3d6bae31195b425f2f8 (diff)
downloadCompiler-446c2394ec8970198d645bbbb462c67b9e3f1b1e.tar.gz
Compiler-446c2394ec8970198d645bbbb462c67b9e3f1b1e.zip
Changing ast structure again
Diffstat (limited to 'test_compiler.sh')
-rwxr-xr-xtest_compiler.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/test_compiler.sh b/test_compiler.sh
new file mode 100755
index 0000000..3f64457
--- /dev/null
+++ b/test_compiler.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# script to test the lexer
+
+echo "========================================"
+echo " Cleaning the temporaries and outputs"
+make clean
+echo " Force building lexer"
+make -B bin/c_compiler
+
+if [[ "$?" -ne 0 ]]; then
+ echo "Build failed.";
+fi
+
+echo ""
+echo ""
+echo "========================================="
+echo " Testing compiler"
+
+PASSED=0
+CHECKED=0
+
+for i in c_compiler/test/in/*.c; do
+ echo "==========================="
+ echo ""
+ echo "Input file : ${i}"
+ BASENAME=$(basename $i .c);
+ cat $i | ./bin/c_compiler > c_compiler/test/out/$BASENAME.stdout.s 2> c_compiler/test/out/$BASENAME.stderr.txt
+
+ diff <(cat c_compiler/test/ref/$BASENAME.stdout.s) <(cat c_compiler/test/out/$BASENAME.stdout.s) > c_compiler/test/out/$BASENAME.diff.txt
+
+ if [[ "$?" -ne "0" ]]; then
+ echo -e "\nERROR"
+ else
+ PASSED=$(( ${PASSED}+1 ));
+ fi
+
+ CHECKED=$(( ${CHECKED}+1 ));
+done
+
+echo "########################################"
+echo "Passed ${PASSED} out of ${CHECKED}".
+echo ""