Skip to content

Commit

Permalink
Tmain: provide the way to skip a test case
Browse files Browse the repository at this point in the history
If a test case exits with code 77, the comparisons
are never done. It is just skipped.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Jul 3, 2015
1 parent 01ac804 commit 383aa71
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Tmain/tmain-skip-example.d/run.sh
@@ -0,0 +1,6 @@
if ${CTAGS} --list-features | grep -q afasdfasfasfsa; then
echo
else
echo "exapmle: no such feature"
exit 77
fi
1 change: 1 addition & 0 deletions Tmain/tmain-skip-example.d/stdout-expected.txt
@@ -0,0 +1 @@
THIS FILE WILL NOT BE USE.
2 changes: 2 additions & 0 deletions docs/tmain.rst
Expand Up @@ -37,6 +37,8 @@ In the example, *Tmain* does:

See also `tmain_run` and `tmain_compare` functions in `misc/units`.

If run.sh exits with code 77, the test case is skipped.


TODO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
17 changes: 16 additions & 1 deletion misc/units
Expand Up @@ -1630,6 +1630,7 @@ tmain_compare()
fi
}

CODE_FOR_IGNORING_THIS_TMAIN_TEST=77
tmain_run ()
{
local topdir=$1
Expand All @@ -1643,6 +1644,8 @@ tmain_run ()
local aspect
local engine

local r
local a
local status=0

basedir=$(pwd)
Expand All @@ -1661,7 +1664,19 @@ tmain_run ()
cd ${subdir}
${SHELL} run.sh ${basedir}/${CTAGS} ${basedir}/${DATADIR} ${basedir}/${LIBEXECDIR}
) > ${subdir}/stdout-actual.txt 2> ${subdir}/stderr-actual.txt
echo $? > ${subdir}/exit-actual.txt
r=$?
echo $r > ${subdir}/exit-actual.txt

if [ $r = $CODE_FOR_IGNORING_THIS_TMAIN_TEST ]; then
run_result skip '/dev/null' "$(cat ${subdir}/stdout-actual.txt)"
for a in ${subdir}/*-actual.txt; do
if [ -f "$a" ]; then
rm $a
fi
done
echo
continue
fi

if [ -f ${subdir}/tags ]; then
mv ${subdir}/tags ${subdir}/tags-actual.txt
Expand Down

0 comments on commit 383aa71

Please sign in to comment.