]> Cypherpunks.ru repositories - goredo.git/blob - t/apenwarr/260-whichdo/nonexists.do
More apenwarr/redo redo-whichdo behaviour resembling
[goredo.git] / t / apenwarr / 260-whichdo / nonexists.do
1 exec >&2
2
3 # Testing the search path for non-existent do files is a little tricky.
4 # We can't be sure where our current directory is, so we don't know how
5 # far up the stack redo will need to search.
6 #
7 # To dodge the problem, let's "cd /" first so that we're testing a target
8 # relative to a known location (the root directory).
9
10 if [ -e '/default.do' -o \
11      -e '/default.z.do' -o \
12      -e '/default.y.z.do' ]; then
13     echo "Weird: /default.*.do exists; can't run this test."
14     exit 99
15 fi
16
17 # redo-whichdo *should* fail here, so don't abort the script for that.
18 set +e
19 a=$(cd / && redo-whichdo __nonexist/a/x.y.z)
20 rv=$?
21 set -e
22
23 if [ "$rv" -eq 0 ]; then
24     echo "redo-whichdo should return nonzero for a missing .do file."
25     exit 10
26 fi
27
28 b=$(cat <<EOF
29 __nonexist/a/x.y.z.do
30 __nonexist/a/default.y.z.do
31 __nonexist/a/default.z.do
32 __nonexist/a/default.do
33 __nonexist/default.y.z.do
34 __nonexist/default.z.do
35 __nonexist/default.do
36 default.y.z.do
37 default.z.do
38 default.do
39 EOF
40 )
41
42 if [ "$a" != "$b" ]; then
43     printf 'redo-whichdo mismatch.\n\ngot:\n%s\n\nexpected:\n%s\n' "$a" "$b"
44     exit 11
45 fi