tests: expose automake bug#14560
[platform/upstream/automake.git] / t / dist-repeated.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 that we can distribute the same file as many times as we want.
18 # The distdir target should take care of not copying it more than one
19 # time anyway.
20
21 . test-init.sh
22
23 echo AC_OUTPUT >> configure.ac
24
25 cat > Makefile.am <<'END'
26 bin_PROGRAMS = foo bar
27 foo_SOURCES = foo.c
28 bar_SOURCES = foo.c
29 python_PYTHON = bar.py
30 EXTRA_DIST = foo.c bar.py
31
32 .PHONY: sanity-check
33 sanity-check:
34         for f in $(DISTFILES); do echo " $$f "; done > dist.txt
35         cat dist.txt
36         test `grep ' foo\.c '  dist.txt | wc -l` -eq 3
37         test `grep ' bar\.py ' dist.txt | wc -l` -eq 2
38
39 # So that we don't have to require a C compiler.
40 AUTOMAKE_OPTIONS = no-dependencies
41 CC = false
42
43 # So that we don't have to require a Python interpreter.
44 pythondir = ${prefix}/py
45 PYTHON = false
46 END
47
48 ocwd=$(pwd) || fatal_ "cannot get current working directory"
49
50 # Help to ensure cp won't see the same file twice.
51 mkdir bin
52 cat > bin/cp <<END
53 #!/bin/sh
54 PATH='$PATH'; export PATH
55
56 case " \$* " in
57   *foo.c\ *)
58     if test -f '$ocwd'/foo-c-copied; then
59       echo "\$0: we tried to copy foo.c twice" >&2
60       exit 1
61     else
62       # For a sanity check later.
63       echo ok > '$ocwd'/cp-wrapper-has-seen-foo-c
64     fi
65     ;;
66 esac
67
68 case " \$* " in
69   *bar.py\ *)
70     if test -f '$ocwd'/bar-py-copied; then
71       echo "\$0: we tried to copy bar.py twice" >&2
72       exit 1
73     else
74       # For a sanity check later.
75       echo ok > '$ocwd'/cp-wrapper-has-seen-bar-py
76     fi
77     ;;
78 esac
79
80 exec cp "\$@"
81 END
82 chmod a+x bin/cp
83 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH;
84
85 : > foo.c
86 : > bar.py
87 : > py-compile
88
89 # Help to ensure cp won't try to copy the same file twice.
90 chmod a-w foo.c bar.py
91
92 $ACLOCAL
93 $AUTOCONF
94 $AUTOMAKE
95
96 ./configure
97 $MAKE sanity-check || fatal_ "expected invariants not verified"
98 $MAKE distdir
99 test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \
100   || fatal_ "our cp wrapper hasn't run correctly"
101
102 :