From: Michal Sojka Date: Wed, 16 Jan 2008 07:50:00 +0000 (+0000) Subject: If a single runtest script is executed by hand and sources functions.sh, tester.py... X-Git-Tag: v0.1~42 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/commitdiff_plain/72d382c3f3e18e59651af32d3ce571fbdbfd0f89 If a single runtest script is executed by hand and sources functions.sh, tester.py is automatically executed in current directory. darcs-hash:20080116075002-f2ef6-745a3c56ae6e21ab86ab47dfdff9d967754d15d0.gz --- diff --git a/tests/functions.sh b/tests/functions.sh index dc4b7a8..97f6679 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -1,5 +1,22 @@ # -*-sh-*- +function findup() { + local arg="$1" + if test -z "$arg"; then return 1; fi + + local wd=$PWD + while ! test -f "$arg"; do + cd .. + if test "$PWD" = "/"; then + cd $wd + exit 1 + fi + done + + echo $PWD/$arg + cd $wd +} + function error() { echo $1 > _error exit 1 @@ -9,3 +26,14 @@ function canttest() { echo $1 > _error exit 2 } + +if [ -z "$OMK_TESTSROOT" ]; then + # We are not called by tester.py - probably, a single test was + # executed by hand. + + tester=$(findup tester.py) + python $tester # Run tester in the current + # directory + exit +fi +