tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / self-check-sanity.sh
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 # Test the sanity checks performed by the 'defs' script.  Also check
19 # that we can use 'defs' elsewhere, when we duplicate some of the
20 # infrastructure from the automake/tests subdirectory.
21
22 am_create_testdir=empty
23 . ./defs || Exit 1
24
25 # Avoid to confuse traces from child processed with our own traces.
26 show_stderr ()
27 {
28   sed 's/^/ | /' stderr >&2
29 }
30
31 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
32
33 if $SHELL -c '. ../defs' dummy.test 2>stderr; then
34   show_stderr
35   Exit 1
36 else
37   show_stderr
38   grep 'defs-static: not found in current directory' stderr
39 fi
40
41 sed 's|^testsrcdir=.*|testsrcdir=foo|' ../defs-static > defs-static
42 if $SHELL -c '. ../defs' dummy.test 2>stderr; then
43   show_stderr
44   Exit 1
45 else
46   show_stderr
47   grep 'foo/defs-static\.in not found.*check \$testsrcdir' stderr
48 fi
49
50 sed 's|^testbuilddir=.*|testbuilddir=foo|' ../defs-static > defs-static
51 if $SHELL -c '. ../defs' dummy.test 2>stderr; then
52   show_stderr
53   Exit 1
54 else
55   show_stderr
56   grep 'foo/defs-static not found.*check \$testbuilddir' stderr
57 fi
58
59 # We still need a little hack to make ./defs work outside automake's
60 # tree 'tests' subdirectory.  Not a big deal.
61 sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
62 # Redefining *srcdir and *builddir variables in the environment shouldn't
63 # cause problems
64 env \
65   builddir=bad-dir srcdir=bad-dir \
66   top_builddir=bad-dir top_srcdir=bad-dir \
67   abs_builddir=bad-dir abs_srcdir=bad-dir \
68   abs_top_builddir=bad-dir abs_top_srcdir=bad-dir \
69   $SHELL -c  '. ../defs && echo "!OK!" > ../foo' dummy.test
70 $FGREP '!OK!' foo
71
72 :