tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / check4.sh
1 #! /bin/sh
2 # Copyright (C) 2005-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 # Make sure 'make -k check' processes all directories.
18
19 . ./defs || Exit 1
20
21 cat >> configure.ac << 'END'
22 AC_CONFIG_FILES([dir/Makefile])
23 AC_OUTPUT
24 END
25
26 mkdir dir
27
28 cat > Makefile.am <<'END'
29 SUBDIRS = dir
30 TESTS = ok.sh
31 END
32
33 echo TESTS = fail.sh >dir/Makefile.am
34
35 cat >ok.sh <<'END'
36 #!/bin/sh
37 :
38 END
39
40 cat >dir/fail.sh <<'END'
41 #!/bin/sh
42 exit 1
43 END
44
45 chmod +x ok.sh dir/fail.sh
46
47 $ACLOCAL
48 $AUTOCONF
49 $AUTOMAKE --add-missing
50
51 ./configure --prefix "`pwd`/inst"
52
53 $MAKE check >stdout && { cat stdout; Exit 1; }
54 cat stdout
55 grep '^FAIL: fail\.sh *$' stdout
56 grep '^PASS: ok\.sh *$' stdout && Exit 1
57
58 # The exit status of 'make -k' can be anything
59 # (depending on the Make implementation)
60 $MAKE -k check >stdout || :
61 cat stdout
62 grep '^FAIL: fail\.sh *$' stdout
63 grep '^PASS: ok\.sh *$' stdout
64
65 # Should also works when -k is not in first position.
66 $MAKE -s -k check >stdout || :
67 cat stdout
68 grep '^FAIL: fail\.sh *' stdout
69 grep '^PASS: ok\.sh *' stdout
70
71 # The rest of the test is for GNU Make.
72
73 if using_gmake; then
74   # Try with a long-option that do not have a short option equivalent
75   # (here, --no-print-directory).  That should cause all options to
76   # appear verbatim in MAKEFLAGS.
77   $MAKE --no-print-directory -k check >stdout || :
78   cat stdout
79   grep '^FAIL: fail\.sh *$' stdout
80   grep '^PASS: ok\.sh *$' stdout
81 fi
82
83 :