2bdcc35dfd6f46a82cab61ddd8d076eed49b0013
[platform/upstream/automake.git] / tests / vtexi4.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 # Check that the version.texi file is automatically created and distributed
18 # if @included into a texi source.  Also check that is correctly defined
19 # @values definitions it is advertised to.
20 # See also the related test `vtexi3.test', which does similar checks, but
21 # for more vers*.texi files, and does not require makeinfo, tex and
22 # texi2dvi.
23
24 required='makeinfo tex texi2dvi-o'
25 . ./defs || Exit 1
26
27 case `LC_ALL=C date '+%u'` in
28   [1-7]) date_is_posix=:;;
29       *) date_is_posx=false;;
30 esac
31 $date_is_posix \
32   && day=`LC_ALL=C date '+%d'` && test -n "$day" \
33   && month=`LC_ALL=C date '+%B'` && test -n "$month" \
34   && year=`LC_ALL=C date '+%Y'`&& test -n "$year" \
35   || skip_ "'date' is not POSIX-compliant enough"
36 day=`echo "$day" | sed 's/^0//'`
37
38 (echo '\ex\a' | grep x) \
39   || skip_ "grep doesn't work on input that is not pure text"
40
41 cat > configure.in << END
42 AC_INIT([$me], [123.456])
43 AM_INIT_AUTOMAKE
44 AC_CONFIG_FILES([Makefile])
45 AC_OUTPUT
46 END
47
48 cat > defs.am <<END
49 my_date_rx = $day $month $year
50 my_month_rx = $month $year
51 my_version_rx = 123\.456
52 END
53
54 cat > Makefile.am << 'END'
55 include defs.am
56 info_TEXINFOS = foo.texi
57 test-grepinfo:
58 ## Not useless uses of cat: we only tested that grep worked on
59 ## non-text input when that's given from a pipe.
60         cat $(srcdir)/foo.info | grep 'GREPVERSION=$(my_version_rx)='
61         cat $(srcdir)/foo.info | grep 'GREPEDITION=$(my_version_rx)='
62         cat $(srcdir)/foo.info | grep 'GREPDATE=$(my_date_rx)='
63         cat $(srcdir)/foo.info | grep 'GREPMONTH=$(my_month_rx)='
64 test-distfiles:
65         @echo DISTFILES = $(DISTFILES)
66         echo ' ' $(DISTFILES) ' ' | grep '[ /]version.texi '
67 test-distdir: distdir
68         ls -l $(distdir)
69         diff $(srcdir)/version.texi $(distdir)/version.texi
70 .PHONY: test-grepinfo test-distfiles test-distdir
71 check-local: test-grepinfo test-distfiles test-distdir
72 END
73
74 cat > foo.texi << 'END'
75 \input texinfo
76 @c %**start of header
77 @setfilename foo.info
78 @settitle Zardoz
79 @c %**end of header
80
81 @node Top
82 @include version.texi
83
84 GREPVERSION=@value{VERSION}=
85
86 GREPEDITION=@value{EDITION}=
87
88 GREPDATE=@value{UPDATED}=
89
90 GREPMONTH=@value{UPDATED-MONTH}=
91
92 @bye
93 END
94
95 $ACLOCAL
96 $AUTOCONF
97 $AUTOMAKE -a
98
99 ./configure
100 $MAKE all dvi
101
102 # Debugging & sanity checks.
103 ls -l
104 cat version.texi
105 cat foo.info
106 test -f foo.dvi
107
108 $MAKE test-grepinfo
109 $MAKE test-distfiles
110 $MAKE test-distdir
111 $MAKE distcheck
112
113 :