[debhelper-devel] [debhelper] 01/01: Add some tests for for dh_installdocs

Niels Thykier nthykier at moszumanska.debian.org
Sat Jul 16 14:43:03 UTC 2016


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit d2bf014000a296e29030a443f78c7dbc92696cf6
Author: Sven Joachim <svenjoac at gmx.de>
Date:   Mon Jul 11 18:12:54 2016 +0200

    Add some tests for for dh_installdocs
    
    This is a small test suite for dh_installdocs, motivated by the problems
    found in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=830309.  It
    catches both the bug introduced in commit 71007f72da682dd9d7f932d81ca
    and the regression caused by commit 863ef397c939340e863be1e96c822934a.
    
    The tests verify that the correct /usr/share/doc symlinks and
    directories are set up with and without the --link-doc option, in both
    compat level 9 and 11.
    
    Since dh_installdocs runs chown(1), the tests are skipped if run by an
    ordinary user and fakeroot is unavailable.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Makefile                          |  2 +-
 debian/changelog                  |  2 +
 t/dh_installdocs/debian/changelog |  5 +++
 t/dh_installdocs/debian/compat    |  1 +
 t/dh_installdocs/debian/control   | 20 ++++++++++
 t/dh_installdocs/debian/docfile   |  1 +
 t/dh_installdocs/dh_installdocs.t | 78 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 108 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 9c2e9f9..e27779b 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,6 @@ install:
 	install -m 0644 Debian/Debhelper/Buildsystem/*.pm $(DESTDIR)$(PERLLIBDIR)/Buildsystem
 
 test: version
-	./run perl -MTest::Harness -e 'runtests grep { ! /CVS/ && ! /\.svn/ && -f && -x } @ARGV' t/* t/buildsystems/*
+	./run perl -MTest::Harness -e 'runtests grep { ! /CVS/ && ! /\.svn/ && -f && -x } @ARGV' t/* t/*/*
 	# clean up log etc
 	./run dh_clean
diff --git a/debian/changelog b/debian/changelog
index 3f28166..3791ee4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ debhelper (9.20160709+unreleased) UNRELEASED; urgency=medium
 
   * dh_installdocs: Apply patch from Sven Joachim to make
     --link-doc work again in compat 11 (See: #830309)
+  * t: Apply patch from Sven Joachim to add some test cases
+    to dh_installdocs's --link-doc behaviour.
 
  -- Niels Thykier <niels at thykier.net>  Sat, 09 Jul 2016 11:51:46 +0000
 
diff --git a/t/dh_installdocs/debian/changelog b/t/dh_installdocs/debian/changelog
new file mode 100644
index 0000000..5850f0e
--- /dev/null
+++ b/t/dh_installdocs/debian/changelog
@@ -0,0 +1,5 @@
+foo (1.0-1) unstable; urgency=low
+
+  * Initial release. (Closes: #XXXXXX)
+
+ -- Test <testing at nowhere>  Mon, 11 Jul 2016 18:10:59 +0200
diff --git a/t/dh_installdocs/debian/compat b/t/dh_installdocs/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/t/dh_installdocs/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/t/dh_installdocs/debian/control b/t/dh_installdocs/debian/control
new file mode 100644
index 0000000..48d4de2
--- /dev/null
+++ b/t/dh_installdocs/debian/control
@@ -0,0 +1,20 @@
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing at nowhere>
+Standards-Version: 3.9.8
+
+Package: foo
+Architecture: all
+Description: package foo
+ Package foo
+
+Package: bar
+Architecture: all
+Description: package bar
+ Package bar
+
+Package: baz
+Architecture: all
+Description: package baz
+ Package baz
diff --git a/t/dh_installdocs/debian/docfile b/t/dh_installdocs/debian/docfile
new file mode 100644
index 0000000..2719eec
--- /dev/null
+++ b/t/dh_installdocs/debian/docfile
@@ -0,0 +1 @@
+This file must not be empty, or dh_installdocs won't install it.
diff --git a/t/dh_installdocs/dh_installdocs.t b/t/dh_installdocs/dh_installdocs.t
new file mode 100755
index 0000000..2c7b381
--- /dev/null
+++ b/t/dh_installdocs/dh_installdocs.t
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+use strict;
+use Test::More;
+use File::Basename ();
+
+# Let the tests be run from anywhere, but current directory
+# is expected to be the one where this test lives in.
+chdir File::Basename::dirname($0) or die "Unable to chdir to ".File::Basename::dirname($0);
+
+my $TOPDIR = "../..";
+my $rootcmd;
+
+if ($< == 0) {
+	$rootcmd = '';
+}
+else {
+	system("fakeroot true 2>/dev/null");
+	$rootcmd = $? ? undef : 'fakeroot';
+}
+
+if (not defined($rootcmd)) {
+	plan skip_all => 'fakeroot required';
+}
+else {
+	plan(tests => 17);
+}
+
+system("rm -rf debian/foo debian/bar debian/baz");
+
+my $doc = "debian/docfile";
+
+system("$rootcmd $TOPDIR/dh_installdocs -pbar $doc");
+ok(-e "debian/bar/usr/share/doc/bar/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+#regression in debhelper 9.20160709 (#830309)
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installdocs -pbar $doc");
+ok(-e "debian/bar/usr/share/doc/foo/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+#regression in debhelper 9.20160702 (#830309)
+system("$rootcmd $TOPDIR/dh_installdocs -pbaz --link-doc=foo $doc");
+ok(-l "debian/baz/usr/share/doc/baz");
+ok(readlink("debian/baz/usr/share/doc/baz") eq 'foo');
+ok(-e "debian/baz/usr/share/doc/foo/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installdocs -pbaz --link-doc=foo $doc");
+ok(-l "debian/baz/usr/share/doc/baz");
+ok(readlink("debian/baz/usr/share/doc/baz") eq 'foo');
+ok(-e "debian/baz/usr/share/doc/foo/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installdocs -pbaz --link-doc=bar $doc");
+ok(-l "debian/baz/usr/share/doc/baz");
+ok(readlink("debian/baz/usr/share/doc/baz") eq 'bar');
+ok(-e "debian/baz/usr/share/doc/foo/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+system("$rootcmd $TOPDIR/dh_installdocs -pfoo --link-doc=bar $doc");
+ok(-l "debian/foo/usr/share/doc/foo");
+ok(readlink("debian/foo/usr/share/doc/foo") eq 'bar');
+ok(-e "debian/foo/usr/share/doc/bar/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installdocs -pfoo --link-doc=bar $doc");
+ok(-l "debian/foo/usr/share/doc/foo");
+ok(readlink("debian/foo/usr/share/doc/foo") eq 'bar');
+ok(-e "debian/foo/usr/share/doc/bar/docfile");
+system("rm -rf debian/foo debian/bar debian/baz");
+
+system("$TOPDIR/dh_clean");
+
+# Local Variables:
+# indent-tabs-mode: t
+# tab-width: 4
+# cperl-indent-level: 4
+# End:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list