2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
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)
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.
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/>.
17 # Sanity check for the automake testsuite.
18 # Make sure that $me gets automatically defined by './defs', and that it
19 # can be overridden by the test script.
26 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
28 # This test becomes cumbersome if we keep the 'errexit' shell flag set.
29 # And removing it is no big deal, as this test is a TAP-based one, so
30 # that false positives remain very unlikely.
35 $AM_TEST_RUNNER_SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$"
36 command_ok_ "me=$1" test $? -eq 0
40 do_check foo-bar-.$e 'foo-bar-'
41 do_check _foo__bar.$e '_foo__bar'
43 do_check a.b.c.$e 'a\.b\.c'
46 do_check foo.bar 'foo\.bar'
49 # If we override $me, ./defs should not modify it.
51 s=$($AM_TEST_RUNNER_SHELL -c 'me=foo.sh && . ./defs && echo me=$me' bad.sh)
52 command_ok_ "override of \$me before ./defs causes no error" \
56 printf '%s\n' "$s" | grep '^me=foo\.sh$' || r='not ok'
57 printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
58 result_ "$r" "override of \$me before ./defs is honored"
61 # Overriding $me after sourcing ./defs-static should work.
62 s=$($AM_TEST_RUNNER_SHELL -c '. ./defs-static && me=zardoz &&
63 . ./defs && echo me=$me' bad.sh)
64 command_ok_ "override of \$me after ./defs-static causes no error" \
68 printf '%s\n' "$s" | grep '^me=zardoz$' || r='not ok'
69 printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
70 result_ "$r" "override of \$me after ./defs-static is honored"