]> rtime.felk.cvut.cz Git - omk.git/commitdiff
If a single runtest script is executed by hand and sources functions.sh, tester.py...
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Jan 2008 07:50:00 +0000 (07:50 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Jan 2008 07:50:00 +0000 (07:50 +0000)
darcs-hash:20080116075002-f2ef6-745a3c56ae6e21ab86ab47dfdff9d967754d15d0.gz

tests/functions.sh

index dc4b7a8aa152a6995be1ed3abbe17ac1a6c829d0..97f6679edff2af15fcb40fa956c2aadcd2cf35a6 100644 (file)
@@ -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
+