tests: more meaningful names for some test cases
[platform/upstream/automake.git] / t / yacc-subdir.sh
1 #! /bin/sh
2 # Copyright (C) 2002-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 # Test for subdir parsers.
18
19 required='cc yacc'
20
21 . ./defs || exit 1
22
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_PROG_YACC
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 AUTOMAKE_OPTIONS = subdir-objects
32 bin_PROGRAMS = foo/foo
33 foo_foo_SOURCES = foo/parse.y
34 AM_YFLAGS = -d
35
36 .PHONY: obj
37 obj: foo/parse.$(OBJEXT)
38
39 .PHONY: test1 test2
40 test1: foo/parse.$(OBJEXT)
41         test -f foo/parse.c
42         test -f foo/parse.$(OBJEXT)
43 test2: foo/parse2.$(OBJEXT)
44         test -f foo/parse2.c
45         test -f foo/parse2.$(OBJEXT)
46 END
47
48 mkdir foo
49
50 cat > foo/parse.y << 'END'
51 %{
52 int yylex () { return 0; }
53 void yyerror (char *s) {}
54 %}
55 %%
56 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
57 END
58
59 $ACLOCAL
60 $AUTOCONF
61 $AUTOMAKE -a
62
63 mkdir sub
64 cd sub
65
66 ../configure
67 $MAKE test1
68
69 # Aside of the rest of this test, let's see if we can recover from
70 # parse.h removal.
71 test -f foo/parse.h
72 rm -f foo/parse.h
73 $MAKE foo/parse.h
74 test -f foo/parse.h
75
76 # Make sure foo/parse.h is not updated, unless when needed.
77 $sleep
78 touch ../foo/parse.y
79 $MAKE obj
80 is_newest ../foo/parse.y foo/parse.h
81 $sleep
82 sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
83 mv -f ../foo/parse.yt ../foo/parse.y
84 $MAKE obj
85 is_newest foo/parse.h ../foo/parse.y
86
87 # Now, adds another parser to test ylwrap.
88
89 cd ..
90
91 # Sleep some to make sure timestamp of Makefile.am will change.
92 $sleep
93
94 cp foo/parse.y foo/parse2.y
95 cat >> Makefile.am << 'END'
96 EXTRA_foo_foo_SOURCES = foo/parse2.y
97 END
98
99 $AUTOMAKE -a
100 test -f ./ylwrap
101
102 cd sub
103 # Regenerate Makefile (automatic in GNU Make, but not in other Makes).
104 ./config.status
105 $MAKE test2
106
107 :