Skip to content

Commit

Permalink
Fix overlapping code and regression, mv colorecho -> color
Browse files Browse the repository at this point in the history
  • Loading branch information
amerlyq committed Nov 30, 2015
1 parent 7ee8305 commit f064aa0
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions t/suite.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
cd $(dirname $(readlink -m ${0}))

case "$1" in --verbose) VERBOSE=1; shift ;; *) VERBOSE=0 ;; esac
case "$1" in -v|--verbose) VERBOSE=1; shift ;; *) VERBOSE=0 ;; esac
VIM=vim

colorecho() { printf "%s" "$(tput setaf $1)${@:2}$(tput sgr0)"; }
getdependencies() {
color() { printf "%s" "$(tput setaf $1)${@:2}$(tput sgr0)"; }
get_deps() {
rm -rf vader.vim
git clone -b master --single-branch --depth=1 \
https://github.com/junegunn/vader.vim && echo
Expand All @@ -20,17 +21,10 @@ utest() {
local file="$1" name="${1%.vader}"
local title="$(sed -rn '/^"""\s*([^"].*)/ s//\1/p' $file)"
local expect="$(sed -rn '/^\s*""""\s*/ s///p' $file)"
local entry="$(colorecho 4 ${name}) ${title}"
local entry="$(color 4 ${name}) ${title}"

for skp in $SKIP_TESTS; do
if [[ "$name" == "$skp" ]]; then
expect="skip"
break
fi
done
if [[ "$expect" == "skip" ]]; then
echo "$entry $(colorecho 3 skip)"
continue
if [[ " $SKIP_TESTS " =~ " $name " ]]; then
echo "$entry $(color 3 skip)"; continue
fi

tempdir=$(mktemp -d "${name}.XXX")
Expand All @@ -42,19 +36,18 @@ utest() {
in failed) ((RET)) && msg="2 failed correctly" || { msg="1 not failed"; RET=1; }
;; *) ((RET)) && { msg="1 ko"; RET=1; } || msg="2 ok"
esac
echo "$entry $(colorecho $msg)"
echo "$entry $(color $msg)"
}

testsuite() {
getdependencies
for testcase in *.vader; do
utest "$testcase"
done
echo $(if ((${RET=0}))
then colorecho '1 some test failed'
else colorecho '2 test suite passed'
then color '1 some test failed'
else color '2 test suite passed'
fi)
exit $RET
return $RET
}

if (($#)); then test $@; else testsuite; fi
if (($#)); then utest $@; else get_deps && testsuite; fi

0 comments on commit f064aa0

Please sign in to comment.