better test output formatting

This commit is contained in:
nojhan 2012-08-17 12:23:36 +02:00
parent 7f2ed35c41
commit b488a1cda1

26
test.sh
View File

@ -13,12 +13,13 @@ assert()
local OK="\\033[1;32m" local OK="\\033[1;32m"
local NOK="\\033[1;31m" local NOK="\\033[1;31m"
local RAZ="\\033[0;39m" local RAZ="\\033[0;39m"
cols=15
if [[ "$PS1" == *$sub* ]] if [[ "$PS1" == *$sub* ]]
then then
echo -e "${OK}$name\tOK${RAZ}" printf "\e${OK}%-${cols}s %-${cols}s\n${RAZ}" "$name" "OK"
else else
echo -e "${NOK}$name\tNO${RAZ}\t$sub" printf "\e${NOK}%-${cols}s %-${cols}s\n${RAZ}" "$name" "$sub"
fi fi
} }
@ -41,7 +42,7 @@ uname()
nproc() nproc()
{ {
echo "fake uname $@" 1>&2 echo "fake nproc $@" 1>&2
echo 2 echo 2
} }
@ -100,7 +101,7 @@ source ./liquidprompt
_lp_cpu_load() _lp_cpu_load()
{ {
echo "fake _lp_cpu_load $@" 1>&2 echo "fake _lp_cpu_load $@" 1>&2
echo "64" echo "0.64"
} }
# Force erroneous command # Force erroneous command
@ -116,16 +117,17 @@ _lp_set_prompt
echo -e "$PS1" echo -e "$PS1"
assert BattMark BATT assert "Battery Mark" BATT
assert BattLevel 55% assert "Battery Level" 55%
assert Load LOAD32% assert "Load Mark" LOAD
assert "Load Level" 32%
assert User "[\\\u" assert User "[\\\u"
assert Perms : assert Perms :
assert Path $(pwd | sed -e "s|$HOME|~|") assert Path $(pwd | sed -e "s|$HOME|~|")
assert Proxy proxy assert Proxy proxy
assert Error 127 assert Error 127
echo GIT # echo GIT
assert Branch fake_test assert "GIT Branch" fake_test
assert Commits 111 assert "GIT Commits" 111
assert Untrack untracked assert "GIT Untrack" untracked
assert Mark gitmark assert "GIT Mark" gitmark