aboutsummaryrefslogtreecommitdiff
path: root/tests/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-xtests/run.sh32
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/run.sh b/tests/run.sh
index 93cad38..a0eced4 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -1,18 +1,24 @@
#!/bin/bash
+[ $# -ne 1 ] && { echo "Usage: $0 <run | break>"; exit 1; }
+
+##### Arguments #####
wai=$(dirname $(readlink -f $0))
out=$(mktemp)
-int=0
+[ "$1" == "break" ] && int=1 || int=0
+#####################
+##### Utils Functions #####
passed(){
echo -e "$1 ===> \e[32mpassed :)\e[0m"
}
-
fail(){
echo -e "$1 ===> \e[5m\e[31mfail :(\e[0m"
}
-
-[ $# -gt 0 ] && [ $1 == "-b" ] && int=1
+clean(){
+ rm ${out}
+}
+##################### #####
##### Run Integration Tests #####
nb_pass=0
@@ -20,11 +26,11 @@ 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}")
+ expectations="${wai}/${test_name%.*}.out"
+ bash ${test} > "${out}" 2>&1 # Run Test
+ diff_out=$(diff "${out}" "${expectations}")
- if [ ! -z "$log" ]
+ if [ ! -z "${diff_out}" ]
then
fail "${test_name}"
nb_fail=$(( nb_fail + 1 ))
@@ -32,14 +38,16 @@ do
if [ $int -eq 1 ]
then
echo "========== Diff =========="
- diff "${out}" "${expectations}"
- exit 1
+ echo -e "${diff_out}"
+ clean
+ exit 1
fi
else
nb_pass=$(( nb_pass + 1 ))
passed "${test_name}"
fi
done
+clean
#################################
@@ -47,7 +55,3 @@ echo -e "\n===== STATS ====="
echo "${nb_pass} pass"
echo "${nb_fail} fails"
-##### Clear #####
-rm ${out}
-#################
-