mirror of
https://gitlab.com/manzerbredes/i3-colors.git
synced 2025-04-19 03:59:44 +00:00
Improve tests
This commit is contained in:
parent
6fc25b04e8
commit
828d437070
8 changed files with 337 additions and 322 deletions
32
tests/run.sh
32
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}
|
||||
#################
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue