tests: fix a timestamp-related spurious failures
[automake.git] / tests / autodist.test
blob9294bc32e9bc8043a545b161edd4f7eb10d1f123
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 # Check that automake really automatically distributes all the files
18 # it advertises to do.
19 # Related to automake bug#7819.
20 # Keep this test in sync with sister test `autodist-subdir.test'.
22 . ./defs || Exit 1
24 set -e
26 # Ensure we are run from the right directory.
27 # (The last thing we want is to delete some random user files.)
28 test -f ../defs
29 rm -f *
31 cat > configure.in <<END
32 AC_INIT([$me], [1.0])
33 AC_CONFIG_AUX_DIR([.])
34 AM_INIT_AUTOMAKE
35 AC_CONFIG_FILES([Makefile])
36 AC_OUTPUT
37 END
39 $ACLOCAL
40 $AUTOCONF
42 # The automake manual states that the list of automatically-distributed
43 # files should be given by `automake --help'.
44 list=`$AUTOMAKE --help \
45 | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
46 | sed 1d`
47 # Normalize whitespace, just in case.
48 list=`echo $list`
50 test -n "$list"
52 cat > Makefile.am <<'END'
53 include distfiles.am
54 check-local:
55 ## For debugging.
56 @echo DIST_COMMON:
57 @for f in $(DIST_COMMON); do echo " $$f"; done
58 @echo DISTDIR:
59 @ls -l $(distdir) | sed 's/^/ /'
60 ## Now the checks.
61 @for f in $(autodist_list); do \
62 echo "file: $$f"; \
63 test -f $(distdir)/$$f \
64 || { echo $$f: distdir fail >&2; exit 1; }; \
65 ## Some filenames might contain dots, but this won't cause spurious
66 ## failures, and "spurious successes" are so unlikely that they're
67 ## not worth worrying about.
68 echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
69 || { echo $$f: distcom fail >&2; exit 1; }; \
70 done
71 END
73 : First try listing the automatically-distributed files in proper
74 : targets in Makefile.am
76 echo "MAINTAINERCLEANFILES = $list" > distfiles.am
77 for f in $list; do echo "$f :; touch $f"; done >> distfiles.am
79 cat distfiles.am # For debugging.
81 $AUTOMAKE -a
83 ./configure
85 $MAKE distdir
86 autodist_list="$list" $MAKE check
88 $MAKE maintainer-clean
89 test ! -f README # Sanity check.
90 rm -rf $me-1.0 # Remove $(distdir).
92 : Now try creating the automatically-distributed files before
93 : running automake.
95 : > distfiles.am
96 for f in $list; do
97 echo dummy > $f
98 done
100 ls -l # For debugging.
102 $AUTOMAKE
104 ./configure
106 $MAKE distdir
107 autodist_list="$list" $MAKE check