]> rtime.felk.cvut.cz Git - omk.git/blobdiff - tests/functions.sh
Merge branch 'devel-cherrypick'
[omk.git] / tests / functions.sh
index dc4b7a8aa152a6995be1ed3abbe17ac1a6c829d0..6962ed26818a71a350533dd136398c445706e77d 100644 (file)
@@ -1,11 +1,42 @@
 # -*-sh-*-
 
-function error() {
+# Exit on first error
+set -e
+
+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
+}
+
+error() {
     echo $1 > _error
     exit 1
 }
 
-function canttest() {
-    echo $1 > _error
-    exit 2
+canttest() {
+    [ -f _canttest ] || echo $1 > _canttest
+    exit 1
 }
+
+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
+