Skip to content

Commit

Permalink
Feature: special syntax for grouping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
key-amb committed Apr 22, 2016
1 parent 096d9f9 commit 61f96df
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
11 changes: 11 additions & 0 deletions example/group-ex.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
t_ok ok
t_ng ng
T_SUB "child group" ((
t_ok c1
t_ng c2
t_success foo "command 'foo' fails"
T_SUB "grand child" ((
t_ok gc1
t_ng gc2
))
))
23 changes: 22 additions & 1 deletion lib/shove.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ T_TOTAL=0
T_PASS=0
T_FAIL=0

LF=$(printf '\\\012_')
LF=${LF%_}

help() {
pod2text $0
exit 1
Expand Down Expand Up @@ -42,7 +45,25 @@ test_file() {
if [[ $SHOVE_VERBOSE ]]; then
_add "__t_verbose=1"
fi
cat $_t >> $tmp
cat $_t | while read line; do
if [[ "$line" =~ ^[[:space:]]*T_SUB[[:space:]]*.*\(\($ ]]; then
#echo "# '$line' matches group beginning."
#ws=$(echo $line | cut -f1 -d'T')
_item="$(echo $line | sed -e 's/^T_SUB //' | sed -e 's/ (($//')"
subtests+=("${_item}")
echo $line | sed -e "s/T_SUB/(${LF}t_substart/" | \
sed -e 's/ ((//' >> $tmp
elif [[ "$line" =~ ^[[:space:]]*\)\)$ ]]; then
#echo "# '$line' matches group ending."
declare -i num=${#subtests[@]}
last=$((num - 1))
_item="${subtests[$last]}"
subtests=("${subtests[@]:0:$last}")
echo $line | sed -e "s/))/t_subclose${LF})${LF}t_subend '${_item}'/" >> $tmp
else
echo "$line" >> $tmp
fi
done
_add "echo 1..\$__t_total"
_add "t_report $dat"

Expand Down
9 changes: 9 additions & 0 deletions t/group-ex.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
t_ok ok

T_SUB "child group" ((
t_ok c1

T_SUB "grand child" ((
t_ok gc1
))
))

0 comments on commit 61f96df

Please sign in to comment.