At Wednesday 31 March 2010, Stefano Lattarini 
<stefano.lattar...@gmail.com> wrote:
> [CUT]
> > A testsuite addition that covers this would be welcome.  Be sure
> > to not fail if the system doesn't support symlinks (MinGW will
> > emulate ln -s with cp -p).
> 
> I'll write a couple of tests soonish, making them SKIP'd if `ln -s'
> fails, or if `test -h' fails when applied to the resulting
>  "symlink".
Done in the attached patch; however...

> By the way, how is the Automake-generated Makefile expected to
>  behave if a file in e.g. EXTRA_DIST is a broken symlink,
... this is still not tested (I don't know what result should be 
expected in such a situation), and...
>  or a symlink pointing to a directory?
... the test for this is xfailing, since a symlink pointing to a 
directory is not expanded to the corresponding directory when
copied in $(distdir); this is probably due to the use of `cp -fpR'
as "directory-copying command" in distdir.am, where the `-R'
option causes GNU cp not to resolve symlinks -- POSIX seems to
leave unspecified the behaviour of `cp -R' w.r.t. symlinks, if I
understand correctly the description at:
 <http://www.opengroup.org/onlinepubs/009695399/utilities/cp.html>

So what is the right thing to do about this -- patch distdir.am or 
modify the semantic of the new test?

Regards,
    Stefano
From ee859147f10c073a6d7bae822e6a4eb259f35e94 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <stefano.lattar...@gmail.com>
Date: Wed, 31 Mar 2010 23:41:01 +0200
Subject: [PATCH] Check that symlinks are resolved by `make dist'.

* tests/distsolvelinks.test: New test.
* tests/distsolvelinksdir.test: Likewise.
* tests/Makefile.am (TESTS, XFAIL_TESTS): Updated accordingly.
Suggested by observations from Ralf Wildenhues.
---
 ChangeLog                    |    8 ++++
 tests/Makefile.am            |    3 ++
 tests/Makefile.in            |    3 ++
 tests/distsolvelinks.test    |   77 ++++++++++++++++++++++++++++++++++++++++++
 tests/distsolvelinksdir.test |   70 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 161 insertions(+), 0 deletions(-)
 create mode 100755 tests/distsolvelinks.test
 create mode 100755 tests/distsolvelinksdir.test

diff --git a/ChangeLog b/ChangeLog
index be5dbae..cc9939d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-01  Stefano Lattarini  <stefano.lattar...@gmail.com>
+
+	Add tests checking that symlinks are resolved by `make dist'.
+	* tests/distsolvelinks.test: New test.
+	* tests/distsolvelinksdir.test: Likewise.
+	* tests/Makefile.am (TESTS, XFAIL_TESTS): Updated accordingly.
+	Suggested by observations from Ralf Wildenhues.
+
 2010-03-28  Ralf Wildenhues  <ralf.wildenh...@gmx.de>
 
 	Remove uses of @acronym and @sc.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index acc979c..facfad0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,6 +20,7 @@ XFAIL_TESTS =					\
 all.test					\
 auxdir2.test					\
 cond17.test					\
+distsolvelinksdir.test				\
 gcj6.test					\
 txinfo5.test
 
@@ -281,6 +282,8 @@ distcom6.test \
 distcom7.test \
 distdir.test \
 distname.test \
+distsolvelinks.test \
+distsolvelinksdir.test \
 dollar.test \
 dollarvar.test \
 dollarvar2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 1d70152..c94b7b8 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -254,6 +254,7 @@ XFAIL_TESTS = \
 all.test					\
 auxdir2.test					\
 cond17.test					\
+distsolvelinksdir.test				\
 gcj6.test					\
 txinfo5.test
 
@@ -525,6 +526,8 @@ distcom6.test \
 distcom7.test \
 distdir.test \
 distname.test \
+distsolvelinks.test \
+distsolvelinksdir.test \
 dollar.test \
 dollarvar.test \
 dollarvar2.test \
diff --git a/tests/distsolvelinks.test b/tests/distsolvelinks.test
new file mode 100755
index 0000000..51dce57
--- /dev/null
+++ b/tests/distsolvelinks.test
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that distributed symlinks in the source tree will be expanded
+# as regular files in $(distdir).
+
+. ./defs || Exit 1
+
+set -e
+
+echo text > file
+
+ln -s file lnk \
+  && cmp file lnk \
+  && test -h lnk \
+  && test ! -h file \
+  || {
+    echo "$me: cannot make and/or detect symlinks" >&2
+    Exit 77
+  }
+
+mkdir A
+mkdir B
+echo aaa > A/aaa
+cd B
+ln -s ../A/aaa bbb
+cd ..
+
+echo FooBarBaz > foo
+
+ln -s foo  bar1
+ln -s bar1 bar2
+ln -s bar2 bar3
+
+ln -s "`pwd`/foo" quux
+
+echo AC_OUTPUT >>configure.in
+
+cat > Makefile.am << 'END'
+EXTRA_DIST = lnk B/bbb bar1 bar2 bar3 quux
+.PHONY: printdistdir
+printdistdir:
+	@echo $(distdir)
+END
+
+ls -l . A B
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distdir
+distdir=`$MAKE printdistdir` || Exit 1
+
+ls -l $distdir $distdir/B
+
+set  file lnk  A/aaa B/bbb  foo quux  foo bar1  foo bar2  foo bar3
+while test $# -gt 0; do
+  file=$1; shift; link=$1; shift;
+  test -f $distdir/$link
+  test ! -h $distdir/$link
+  diff $file $distdir/$link
+done
diff --git a/tests/distsolvelinksdir.test b/tests/distsolvelinksdir.test
new file mode 100755
index 0000000..80027eb
--- /dev/null
+++ b/tests/distsolvelinksdir.test
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that distributed symlinks in the source tree which points to
+# a directory will be expanded as directories in $(distdir).
+
+. ./defs || Exit 1
+
+set -e
+
+mkdir dir
+echo text > dir/file
+
+ln -s dir ldir \
+  && test -f ldir/file \
+  && cmp dir/file ldir/file \
+  && test -h ldir \
+  && test ! -h dir \
+  || {
+    echo "$me: cannot make and/or detect symlinks to directories" >&2
+    Exit 77
+  }
+
+ln -s "`pwd`/dir" ldir2
+
+ln -s ldir lldir
+ln -s lldir llldir
+
+echo AC_OUTPUT >>configure.in
+
+cat > Makefile.am << 'END'
+EXTRA_DIST = ldir ldir2 lldir llldir
+.PHONY: printdistdir
+printdistdir:
+	@echo $(distdir)
+END
+
+ls -l . dir
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distdir
+distdir=`$MAKE printdistdir` || Exit 1
+
+ls -l $distdir
+ls -l $distdir/*
+
+for d in ldir ldir2 lldir llldir; do
+  test -d $distdir/$d
+  test ! -h $distdir/$d
+  test -f $distdir/$d/file
+  test ! -h $distdir/$d/file
+  diff dir/file $distdir/$d/file
+done
-- 
1.6.5

Reply via email to