Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/test-yesno.sh @ 12404:44954971957b
init.sh: avoid Solaris 10 /bin/sh portability problem
Solaris 10's /bin/sh does not pass '.' arguments 2..N to the
sourced script:
$ printf 'echo "$@"\n' > f; /bin/sh -c '. ./f bar'
$ printf 'echo "$@"\n' > f; bash -c '. ./f bar'
bar
tests/init.sh relied on that, accepting a --set-path=DIR argument,
and two tests used that idiom.
* tests/init.sh: Update suggested usage comments.
(path_prepend_): New function, to be used in place of
the --src-path=DIR option.
Disallow empty strings and strings containing ":".
(setup_): Move PATH-prepending code into path_prepend_.
* tests/test-pread.sh: Adapt to new usage.
* tests/test-xalloc-die.sh: Likewise.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Tue, 08 Dec 2009 20:37:50 +0100 |
parents | 3710e1c3943e |
children | c47783837720 |
rev | line source |
---|---|
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
1 #!/bin/sh |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
2 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
3 tmpfiles= |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
4 trap 'rm -fr $tmpfiles' 1 2 3 15 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
5 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
6 p=t-yesno- |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
7 tmpfiles="${p}in.tmp ${p}xout.tmp ${p}out1.tmp ${p}out.tmp ${p}err.tmp" |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
8 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
9 # For now, only test with C locale |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
10 LC_ALL=C |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
11 export LC_ALL |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
12 |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
13 # Find out how to remove carriage returns from output. Solaris /usr/ucb/tr |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
14 # does not understand '\r'. |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
15 if echo solaris | tr -d '\r' | grep solais > /dev/null; then |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
16 cr='\015' |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
17 else |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
18 cr='\r' |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
19 fi |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
20 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
21 # Test with seekable stdin; the followon process must see remaining data. |
12078
3710e1c3943e
test-yesno: work around sparc-dash here-document infelicity
Jim Meyering <meyering@redhat.com>
parents:
9987
diff
changeset
|
22 tr @ '\177' <<EOF > ${p}in.tmp |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
23 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn - entire line consumed |
12078
3710e1c3943e
test-yesno: work around sparc-dash here-document infelicity
Jim Meyering <meyering@redhat.com>
parents:
9987
diff
changeset
|
24 y@n - backspace does not change result |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
25 y |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
26 does not match either yesexpr or noexpr |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
27 n |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
28 EOF |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
29 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
30 cat <<EOF > ${p}xout.tmp |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
31 N |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
32 Y |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
33 Y |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
34 N |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
35 n |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
36 EOF |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
37 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
38 (./test-yesno${EXEEXT}; ./test-yesno${EXEEXT} 3; cat) \ |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
39 < ${p}in.tmp > ${p}out1.tmp || exit 1 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
40 LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
41 cmp ${p}xout.tmp ${p}out.tmp || exit 1 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
42 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
43 (./test-yesno${EXEEXT} 3; ./test-yesno${EXEEXT}; cat) \ |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
44 < ${p}in.tmp > ${p}out1.tmp || exit 1 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
45 LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
46 cmp ${p}xout.tmp ${p}out.tmp || exit 1 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
47 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
48 # Test for behavior on pipe |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
49 cat <<EOF > ${p}xout.tmp |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
50 Y |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
51 N |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
52 EOF |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
53 echo yes | ./test-yesno${EXEEXT} 2 > ${p}out1.tmp || exit 1 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
54 LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
55 cmp ${p}xout.tmp ${p}out.tmp || exit 1 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
56 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
57 # Test for behavior on EOF |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
58 cat <<EOF > ${p}xout.tmp |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
59 N |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
60 EOF |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
61 ./test-yesno${EXEEXT} </dev/null > ${p}out1.tmp || exit 1 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
62 LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
63 cmp ${p}xout.tmp ${p}out.tmp || exit 1 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
64 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
65 # Test for behavior when stdin is closed |
9987
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
66 ./test-yesno${EXEEXT} 0 <&- > ${p}out1.tmp 2> ${p}err.tmp && exit 1 |
8d1cd7ae4b1e
Make test-yesno.sh work on mingw.
Bruno Haible <bruno@clisp.org>
parents:
9391
diff
changeset
|
67 LC_ALL=C tr -d "$cr" < ${p}out1.tmp > ${p}out.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
68 cmp ${p}xout.tmp ${p}out.tmp || exit 1 |
9391
f91466f94f23
* tests/test-yesno.sh: Silence stderr during test.
Eric Blake <ebb9@byu.net>
parents:
9157
diff
changeset
|
69 test -s ${p}err.tmp || exit 1 |
9157
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
70 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
71 # Cleanup |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
72 rm -fr $tmpfiles |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
73 |
18308c6e516b
Test yesno in combination with closein.
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
74 exit 0 |