aboutsummaryrefslogtreecommitdiff
path: root/tests/run.sh
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2019-10-08 21:59:31 -0400
committerLoic Guegan <manzerbredes@mailbox.org>2019-10-08 21:59:31 -0400
commit5ca2e63ea66095fbe64cdc441f6eec663fb28bd4 (patch)
tree52788dca42469677fdde10d70391db2ff07aa9e5 /tests/run.sh
parent6ba370ea542c6d3ca06cabcf0d3295a2f5ec18b4 (diff)
Add simple integration test framework
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-xtests/run.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755
index 0000000..296eccf
--- /dev/null
+++ b/tests/run.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+wai=$(dirname $(readlink -f $0))
+out=$(mktemp)
+int=0
+
+passed(){
+ echo -e "$1 ===> \e[32mpassed :)\e[0m"
+}
+
+fail(){
+ echo -e "$1 ===> \e[5m\e[31mfail :(\e[0m"
+}
+
+[ $# -gt 0 ] && [ $1 == "-b" ] && int=1
+
+##### Run Integration Tests #####
+nb_pass=0
+nb_fail=0
+for test in $(find ${wai} -type f -name "test-*.sh")
+do
+ test_name=$(basename $test)
+ expectations="${test_name%.*}.out"
+ bash $test > $out 2>&1
+ log=$(diff -q "${out}" "${expectations}")
+
+ if [ ! -z "$log" ]
+ then
+ fail "${test_name}"
+ nb_fail=$(( nb_fail + 1 ))
+
+ if [ $int -eq 1 ]
+ then
+ echo "========== Diff =========="
+ diff "${out}" "${expectations}"
+ exit 1
+ fi
+ else
+ nb_pass=$(( nb_test + 1 ))
+ passed "${test_name}"
+ fi
+done
+#################################
+
+
+echo -e "\n===== STATS ====="
+echo "${nb_pass} pass"
+echo "${nb_fail} fails"
+
+##### Clear #####
+rm ${out}
+#################
+