tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / distlinks.sh
blob7d05b6eeb0c95c3554da23cd51598a39b4967736
1 #! /bin/sh
2 # Copyright (C) 2010-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 # Check that distributed symlinks in the source tree will be expanded
18 # as regular files in $(distdir).
20 . ./defs || exit 1
22 echo text > file
24 ln -s file lnk || skip_ "cannot create symlinks to files"
26 mkdir A
27 mkdir B
28 echo aaa > A/aaa
29 cd B
30 ln -s ../A/aaa bbb
31 cd ..
33 echo FooBarBaz > foo
35 ln -s foo bar1
36 ln -s bar1 bar2
37 ln -s bar2 bar3
39 ln -s "$(pwd)/foo" quux
41 cat >> configure.ac << 'END'
42 AC_OUTPUT
43 END
45 echo "me = $me" > Makefile.am # For better failure messages.
46 cat >> Makefile.am << 'END'
47 EXTRA_DIST = lnk B/bbb bar1 bar2 bar3 quux
48 .PHONY: test
49 test: distdir
50 ls -l $(distdir) $(distdir)/B
51 fail() { echo "$(me): $$*" >&2; e=1; }; \
52 e=0; \
53 set file lnk A/aaa B/bbb foo quux foo bar1 foo bar2 foo bar3; \
54 while test $$# -ge 2; do \
55 file=$$1; shift; link=$(distdir)/$$1; shift; \
56 test -f $$link || fail "$$link is not a regular file"; \
57 test ! -h $$link || fail "$$link is a symlink"; \
58 diff $$file $$link || fail "$$link differs from $$file"; \
59 done; \
60 exit $$e;
61 END
63 ls -l . A B
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE
69 ./configure
70 $MAKE test