]> rtime.felk.cvut.cz Git - omk.git/blob - tests/functions.sh
7eb0c5215842e29e4dc74c71ecf8bf846d2f89ac
[omk.git] / tests / functions.sh
1 # -*-sh-*-
2
3 # Exit on first error
4 set -e
5
6 function findup() {
7     local arg="$1"
8     if test -z "$arg"; then return 1; fi
9
10     local wd=$PWD
11     while ! test -f "$arg"; do
12         cd ..
13         if test "$PWD" = "/"; then
14             cd $wd
15             exit 1
16         fi
17     done
18     
19     echo $PWD/$arg
20     cd $wd
21 }
22
23 function error() {
24     echo $1 > _error
25     exit 1
26 }
27
28 function canttest() {
29     [ -f _canttest ] || echo $1 > _canttest
30     exit 1
31 }
32
33 if [ -z "$OMK_TESTSROOT" ]; then
34     # We are not called by tester.py - probably, a single test was
35     # executed by hand.
36
37     tester=$(findup tester.py)
38     python $tester                      # Run tester in the current
39                                         # directory
40     exit
41 fi
42