0700991712b676b1d28741ab69ed62d1b51a1e09
[platform/upstream/automake.git] / t / test-extensions.sh
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 # Make sure that Automake diagnose invalid entries in TEST_EXTENSIONS,
18 # and do not diagnose valid (albeit more unusual) ones.
19 # See automake bug#9400.
20
21 . test-init.sh
22
23 cat >> configure.ac <<'END'
24 AC_OUTPUT
25 END
26
27 $ACLOCAL
28 $AUTOCONF
29
30 valid_extensions='sh T t1 _foo BAR x_Y_z _'
31
32 echo TESTS = > Makefile.am
33 echo " $valid_extensions" \
34   | sed -e 's/ / ./g' -e 's/^/TEST_EXTENSIONS =/' >> Makefile.am
35 cat Makefile.am # For debugging.
36
37 $AUTOMAKE -a
38
39 grep -i 'log' Makefile.in # For debugging.
40
41 for lc in $valid_extensions; do
42   uc=$(echo $lc | tr '[a-z]' '[A-Z]')
43   $FGREP "\$(${uc}_LOG_COMPILER)" Makefile.in
44   grep "^${uc}_LOG_COMPILE =" Makefile.in
45   grep "^\.${lc}\.log:" Makefile.in
46 done
47
48 # The produced Makefile is not broken.
49 ./configure
50 $MAKE all check
51
52 cat > Makefile.am << 'END'
53 TESTS = foo.test bar.sh
54 TEST_EXTENSIONS  = .test mu .x-y a-b .t.1 .sh .6c .0 .11 .= @suf@ .@ext@
55 TEST_EXTENSIONS += .= .t33 .a@b _&_
56 END
57
58 AUTOMAKE_fails
59 for suf in mu .x-y a-b .t.1 .6c .0 .11  @suf@ .@ext@ '.=' '_&_'; do
60   suf2=$(printf '%s\n' "$suf" | sed -e 's/\./\\./')
61   $EGREP "^Makefile\.am:2:.*invalid test extension.* $suf2( |$)" stderr
62 done
63
64 # Verify that we accept valid suffixes, even if intermixed with
65 # invalid ones.
66 $EGREP '\.(sh|test|t33)' stderr && exit 1
67
68 # Verify that we don't try to handle invalid suffixes.
69 $EGREP '(LOG_COMPILER|non-POSIX var|bad character)' stderr && exit 1
70
71 :