tests: make 'lzip.test' executable
[automake.git] / tests / install-info-dir.test
blob044bf6d2a5df4fc80f71558d7ef05f9a95769245
1 #! /bin/sh
2 # Copyright (C) 2011 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Checks on the `install-info' target.
18 # Details about the individual checks' purposes and motivations are
19 # inlined, below.
21 # FIXME: this test is a good candidate for a conversion to TAP,
22 # FIXME: and could be merged with `txinfo27.test'.
24 required=makeinfo
25 . ./defs || Exit 1
27 cwd=`pwd` || fatal_ "cannot get current working directory"
29 mkdir bin
30 saved_PATH=$PATH; export saved_PATH
31 PATH=$cwd/bin$PATH_SEPARATOR$PATH; export PATH
33 set -e
35 cat >> configure.in <<'END'
36 AC_OUTPUT
37 END
39 cat > Makefile.am << 'END'
40 info_TEXINFOS = foo.texi
41 END
43 cat > foo.texi << 'END'
44 \input texinfo
45 @setfilename foo.info
46 @c All the following directives might be required to allow older
47 @c versions of the `install-info' program (e.g., version 4.8) to
48 @c create the `dir' index file in ${infodir}. Don't remove them.
49 @settitle foo
50 @dircategory Dummy utilities
51 @direntry
52 * Foo: (foo). Does nothing at all, but has a nice name.
53 @end direntry
54 @node Top
55 Hello world!
56 @bye
57 END
59 $ACLOCAL
60 $AUTOMAKE -a
61 $AUTOCONF
63 instdir=_inst
64 destdir=_dest
66 ./configure --prefix="$cwd/$instdir" --infodir="$cwd/$instdir/info"
68 $MAKE info
69 test -f foo.info
71 if install-info --version; then
72 have_installinfo=yes
73 else
74 have_installinfo=no
77 # The `install-info' target updates the `${infodir}/dir' file
78 # by default (if the `install-info' program is available).
79 # This should happen in a normal as well as in a DESTDIR installation.
80 if test $have_installinfo = yes; then
81 $MAKE install-info
82 test -f $instdir/info/foo.info
83 test -f $instdir/info/dir
84 $MAKE DESTDIR="$cwd/$destdir" install-info
85 test -f "$destdir/$cwd/$instdir"/info/foo.info
86 test -f "$destdir/$cwd/$instdir"/info/dir
89 rm -rf $instdir $destdir
91 # The `install-info' target doesn't fail if the `install-info'
92 # program is not available.
93 cat > bin/install-info <<'END'
94 #!/bin/sh
95 echo error from install-info >&2
96 exit 127
97 END
98 chmod a+x bin/install-info
99 $MAKE install-info >output 2>&1 || { cat output; Exit 1; }
100 cat output
101 test -f $instdir/info/foo.info
102 test ! -f $instdir/info/dir
103 grep 'error from install-info' output && Exit 1
105 rm -rf $instdir output
107 if test $have_installinfo = yes; then
108 # The `install-info' target doesn't try to guess whether the `install-info'
109 # is the GNU or debian version.
110 unindent > bin/install-info <<'END'
111 #!/bin/sh
112 set -e; set -u;
113 for fd in 1 2; do
114 for str in dpkg debian Debian; do
115 eval "echo This is $str install-info >&$fd"
116 done
117 done
118 PATH=$saved_PATH; export PATH
119 exec install-info ${1+"$@"}
121 $MAKE install-info
122 test -f $instdir/info/foo.info
123 test -f $instdir/info/dir
126 rm -rf $instdir bin/install-info
128 # The `AM_UPDATE_INFO_DIR' environment variable can be used to
129 # prevent the creation or update of the `${infodir}/dir' file,
130 # if set to a "no" value.
131 for val in no NO n; do
132 rm -rf $instdir
133 env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
134 test -f $instdir/info/foo.info
135 test ! -f $instdir/info/dir
136 done
137 if test $have_installinfo = yes; then
138 for val in 'yes' 'who cares!'; do
139 rm -rf $instdir
140 env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
141 test -f $instdir/info/foo.info
142 test -f $instdir/info/dir
143 done
146 rm -rf $instdir