On 02/24/2012 08:35 PM, Stefano Lattarini wrote:
> On 02/24/2012 08:25 PM, Stefano Lattarini wrote:
>> (I'll update my patch to have it test also such usage).
>>
> And here it is the updated patch.  I will push it shortly if there is
> no objection.
> 
Maybe it would have been nice actually attaching the patch ... ;-)

Sorry for the confusion,
  Stefano
>From 8f6a79c2a4ff5557142b552c96cfa171e43f52ab Mon Sep 17 00:00:00 2001
Message-Id: <8f6a79c2a4ff5557142b552c96cfa171e43f52ab.1330112034.git.stefano.lattar...@gmail.com>
From: Stefano Lattarini <stefano.lattar...@gmail.com>
Date: Fri, 24 Feb 2012 18:34:04 +0100
Subject: [PATCH] coverage: dist-hook and distcheck-hook can modify file
 permission

See automake bug#10878.

* tests/dist-hook-perms.test: New test, checking that the user can
use the 'dist-hook' target to modify permissions of distributed
files before putting them in the distribution tarball.
* tests/distcheck-writable-srcdir.test: New test, checking that the
user can use 'distcheck-hook' to ensure his packages is built by
"make distcheck" with a writable srcdir.  This goes against the GNU
Coding Standards, but some package authors might not care about
them too much, and it's nice to support their use case too.
* tests/list-of-tests.mk: Add them.
---
 tests/distcheck-writable-srcdir.test |   48 +++++++++++++++++++++++++++
 tests/disthook-perms.test            |   59 ++++++++++++++++++++++++++++++++++
 tests/list-of-tests.mk               |    2 +
 3 files changed, 109 insertions(+), 0 deletions(-)
 create mode 100755 tests/distcheck-writable-srcdir.test
 create mode 100755 tests/disthook-perms.test

diff --git a/tests/distcheck-writable-srcdir.test b/tests/distcheck-writable-srcdir.test
new file mode 100755
index 0000000..bbc50f4
--- /dev/null
+++ b/tests/distcheck-writable-srcdir.test
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2012 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 the user abuse 'distcheck-hook' to ensure his packages
+# is built by "make distcheck" with a writable srcdir.  This goes
+# against the GNU Coding Standards, but some package authors might
+# not care about them too much, and it's nice to support their use
+# case too (since it doesn't cost us anything but this test).
+# See automake bug#10878.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = old
+distcheck-hook:
+	find $(distdir) -exec chmod u+w '{}' ';'
+check-local:
+	test -f $(srcdir)/old
+	test ! -f $(srcdir)/new
+	test ! -r $(srcdir)/new
+## Don't do this in real life, or I'll kill you.
+	echo foo > $(srcdir)/old
+	echo bar > $(srcdir)/new
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+: > old
+$MAKE distcheck
+
+:
diff --git a/tests/disthook-perms.test b/tests/disthook-perms.test
new file mode 100755
index 0000000..a5f0acb
--- /dev/null
+++ b/tests/disthook-perms.test
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2012 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 the user can use the 'dist-hook' target to modify
+# permissions of distributed files before putting them in the
+# distribution tarball.  See automake bug#10878.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = write execute
+dist-hook:
+	chmod u+w $(distdir)/write
+	chmod u+x $(distdir)/execute
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+echo Will be clobbered > write
+cat > execute <<'END'
+#!/bin/sh
+echo I run successfully
+END
+
+chmod a-w write
+chmod a-x execute
+
+$MAKE
+$MAKE dist
+
+test -f $distdir.tar.gz
+gzip -dc $distdir.tar.gz | tar xvf -
+
+cd $distdir
+echo clobber clobber > write
+cat write | grep 'clobber clobber'
+./execute
+./execute | grep 'I run successfully'
+
+:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index eaaa888..e6c87c4 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -353,6 +353,7 @@ distcom2.test \
 distcom3.test \
 distcom4.test \
 distcom5.test \
+dist-hook-perms.test \
 distcom-subdir.test \
 distdir.test \
 distlinks.test \
@@ -363,6 +364,7 @@ distcheck-configure-flags-am.test \
 distcheck-configure-flags-subpkg.test \
 distcheck-hook.test \
 distcheck-hook2.test \
+distcheck-writable-srcdir.test \
 distcheck-missing-m4.test \
 distcheck-outdated-m4.test \
 distcheck-override-infodir.test \
-- 
1.7.9

Reply via email to