tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / self-check-me.tap
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Sanity check for the automake testsuite.
18 # Make sure that $me gets automatically defined by 'test-init.sh'.
19
20 am_create_testdir=no
21 . test-init.sh
22
23 plan_ 12
24
25 # This test becomes cumbersome if we keep the 'errexit' shell flag set.
26 # And removing it is no big deal, as this test is a TAP-based one, so
27 # that false positives remain very unlikely.
28 set +e
29
30 do_check ()
31 {
32   $AM_TEST_RUNNER_SHELL -c '
33     am_create_testdir=no # Do not pollute the top-level directory.
34    . test-init.sh
35     echo me=$me
36   ' "$1" | grep "^me=$2$"
37   command_ok_ "me=$1" test $? -eq 0
38 }
39
40 for e in sh tap; do
41   do_check foo-bar-.$e 'foo-bar-'
42   do_check _foo__bar.$e '_foo__bar'
43   do_check 012.$e '012'
44   do_check a.b.c.$e 'a\.b\.c'
45 done
46
47 do_check foo.bar 'foo\.bar'
48 do_check abc. 'abc\.'
49
50 # A definition of $me in the environment should be ignored.
51
52 s=$(me=bad $AM_TEST_RUNNER_SHELL -c '
53   # Do not pollute the top-level directory.
54   am_create_testdir=no
55  . test-init.sh
56   echo me=$me
57 ' foo.sh)
58 command_ok_ "override of \$me before test-init.sh causes no error" \
59             test $? -eq 0
60
61 r='ok'
62 printf '%s\n' "$s" | grep '^me=foo$' || r='not ok'
63 printf '%s\n' "$s" | grep 'me=bad'   && r='not ok'
64 result_ "$r" "\$me from the environment is ignored"
65 unset r
66
67 :