tests init: don't bother allowing '$me' to be overridable
[platform/upstream/automake.git] / t / self-check-me.tap
1 #! /bin/sh
2 # Copyright (C) 2011-2012 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 './defs'.
19
20 am_create_testdir=no
21 . ./defs || exit 1
22
23 plan_ 12
24
25 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
26
27 # This test becomes cumbersome if we keep the 'errexit' shell flag set.
28 # And removing it is no big deal, as this test is a TAP-based one, so
29 # that false positives remain very unlikely.
30 set +e
31
32 do_check ()
33 {
34   $AM_TEST_RUNNER_SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$"
35   command_ok_ "me=$1" test $? -eq 0
36 }
37
38 for e in sh tap; do
39   do_check foo-bar-.$e 'foo-bar-'
40   do_check _foo__bar.$e '_foo__bar'
41   do_check 012.$e '012'
42   do_check a.b.c.$e 'a\.b\.c'
43 done
44
45 do_check foo.bar 'foo\.bar'
46 do_check abc. 'abc\.'
47
48 # A definition of $me in the environment should be ignored.
49
50 s=$(me=bad $AM_TEST_RUNNER_SHELL -c '. ./defs && echo me=$me' foo.sh)
51 command_ok_ "override of \$me before ./defs causes no error" \
52             test $? -eq 0
53
54 r='ok'
55 printf '%s\n' "$s" | grep '^me=foo$' || r='not ok'
56 printf '%s\n' "$s" | grep 'me=bad'   && r='not ok'
57 result_ "$r" "\$me from the environment is ignored"
58 unset r
59
60 :