aboutsummaryrefslogtreecommitdiff
path: root/tests/run.sh
blob: 93cad384be059c841222a6db5496bfdbb155d0bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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_pass + 1 ))
        passed "${test_name}"
    fi
done
#################################


echo -e "\n===== STATS ====="
echo "${nb_pass} pass"
echo "${nb_fail} fails"

##### Clear #####
rm ${out}
#################