i3-colors/tests/run.sh

62 lines
1.3 KiB
Bash
Raw Normal View History

2019-10-08 21:59:31 -04:00
#!/bin/bash
2019-10-09 10:05:52 -04:00
[ $# -ne 1 ] && { echo "Usage: $0 <run | break>"; exit 1; }
##### Arguments #####
2019-10-08 21:59:31 -04:00
wai=$(dirname $(readlink -f $0))
out=$(mktemp)
2019-10-09 10:05:52 -04:00
[ "$1" == "break" ] && int=1 || int=0
#####################
2019-10-08 21:59:31 -04:00
2019-10-09 10:05:52 -04:00
##### Utils Functions #####
2019-10-08 21:59:31 -04:00
passed(){
echo -e "$1 ===> \e[32mpassed :)\e[0m"
}
fail(){
echo -e "$1 ===> \e[5m\e[31mfail :(\e[0m"
}
2019-10-09 10:05:52 -04:00
clean(){
rm ${out}
}
##################### #####
2019-10-08 21:59:31 -04:00
##### Run Integration Tests #####
nb_pass=0
nb_fail=0
for test in $(find ${wai} -type f -name "test-*.sh")
do
test_name=$(basename $test)
2019-10-09 10:05:52 -04:00
expectations="${wai}/${test_name%.*}.out"
bash ${test} > "${out}" 2>&1 # Run Test
diff_out=$(diff "${out}" "${expectations}")
2019-10-08 21:59:31 -04:00
2019-10-09 10:05:52 -04:00
if [ ! -z "${diff_out}" ]
2019-10-08 21:59:31 -04:00
then
fail "${test_name}"
nb_fail=$(( nb_fail + 1 ))
if [ $int -eq 1 ]
then
echo "========== Diff =========="
2019-10-09 10:05:52 -04:00
echo -e "${diff_out}"
echo "========== Original =========="
cat "${expectations}"
echo "========== Test Output =========="
cat "${out}"
2019-10-09 10:05:52 -04:00
clean
exit 1
2019-10-08 21:59:31 -04:00
fi
else
2019-10-09 08:00:34 -04:00
nb_pass=$(( nb_pass + 1 ))
2019-10-08 21:59:31 -04:00
passed "${test_name}"
fi
done
2019-10-09 10:05:52 -04:00
clean
2019-10-08 21:59:31 -04:00
#################################
echo -e "\n===== STATS ====="
echo "${nb_pass} pass"
echo "${nb_fail} fails"