tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / man4.sh
blob2688b7d471a555e92369c5786d180dca473972b4
1 #! /bin/sh
2 # Copyright (C) 2008-2012 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 # Ensure 'make dist' fails when help2man replacement man pages are created.
19 # The assumption here is the following: if the developer uses help2man to
20 # generate man pages from --help output, then these man pages may not be
21 # stored in VCS. However, they should be distributed, so that the end user
22 # that receives the tarball doesn't have to install help2man. If they are
23 # not distributed, then the developer should make help2man a prerequisite
24 # to building the package from a tarball, e.g., with a configure check for
25 # help2man that errors out if it is unavailable. In both cases it is
26 # sufficient to check only distributed man pages.
28 # Idea of this whole shenanigan is to allow somebody to check out sources from
29 # a VCS and build and install them without needing help2man installed. The
30 # installed man pages will be bogus in this case. Typically, this happens
31 # when developers ask users to try out a fix from VCS; the developers themselves
32 # will usually have help2man installed (or should install it).
34 . ./defs || exit 1
36 cat > Makefile.am << 'END'
37 dist_man_MANS = $(srcdir)/foo.1 bar.1
38 dist_bin_SCRIPTS = foo bar
39 $(srcdir)/foo.1:
40 $(HELP2MAN) --output=$@ $(srcdir)/foo
41 bar.1:
42 $(HELP2MAN) --output=$(srcdir)/bar.1 $(srcdir)/bar
43 END
45 cat >>configure.ac <<'END'
46 AM_MISSING_PROG([HELP2MAN], [help2man])
47 AC_OUTPUT
48 END
50 cat > foo <<'END'
51 #! /bin/sh
52 while test $# -gt 0; do
53 case $1 in
54 -h | --help) echo "usage: $0 [OPTIONS]..."; exit 0;;
55 -v | --version) echo "$0 1.0"; exit 0;;
56 esac
57 shift
58 done
59 END
60 cp foo bar
61 chmod +x foo bar
63 mkdir bin
64 cat > bin/help2man <<'END'
65 #! /bin/sh
66 # Fake help2man script that lets 'missing' think it is not installed.
67 exit 127
68 END
69 chmod +x bin/help2man
70 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
72 grep_error_messages()
74 grep ' man pages contain.*missing help2man.* replacement text' stderr \
75 && grep 'install help2man' stderr \
76 && grep 'regenerate the man pages' stderr \
77 || exit 1
80 $ACLOCAL
81 $AUTOMAKE
82 $AUTOCONF
84 ./configure
85 $MAKE
86 $MAKE dist 2>stderr && { cat stderr >&2; exit 1; }
87 cat stderr >&2
88 grep_error_messages
89 $MAKE distcheck 2>stderr && { cat stderr >&2; exit 1; }
90 cat stderr >&2
91 grep_error_messages
92 $MAKE distclean
94 mkdir build
95 cd build
96 ../configure
97 $MAKE
98 $MAKE dist 2>stderr && { cat stderr >&2; exit 1; }
99 cat stderr >&2
100 grep_error_messages
101 $MAKE distcheck 2>stderr && { cat stderr >&2; exit 1; }
102 cat stderr >&2
103 grep_error_messages