diff options
author | Niels Thykier <niels@thykier.net> | 2017-07-02 15:52:02 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-07-02 15:52:02 +0000 |
commit | 6e6307bb10e8118ea1d5086ff4e3803fcfef1b2a (patch) | |
tree | 40ec4c96275ba347f9457e8a3fdefcd67b9d85bf /t | |
parent | 1e9c94352179e92a54b47a68ee67f6b3d74c4e62 (diff) |
dh_installdocs.t: Migrate to Test::DH
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 't')
-rw-r--r-- | t/dh_installdocs/debian/copyright | 1 | ||||
-rwxr-xr-x | t/dh_installdocs/dh_installdocs.t | 119 |
2 files changed, 60 insertions, 60 deletions
diff --git a/t/dh_installdocs/debian/copyright b/t/dh_installdocs/debian/copyright new file mode 100644 index 00000000..7e6ffb08 --- /dev/null +++ b/t/dh_installdocs/debian/copyright @@ -0,0 +1 @@ +Some test copyright file diff --git a/t/dh_installdocs/dh_installdocs.t b/t/dh_installdocs/dh_installdocs.t index e4b2e76d..34d5a3b4 100755 --- a/t/dh_installdocs/dh_installdocs.t +++ b/t/dh_installdocs/dh_installdocs.t @@ -1,83 +1,82 @@ #!/usr/bin/perl use strict; +use warnings; 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; +use File::Path qw(remove_tree); +use File::Basename qw(dirname); +use lib dirname(dirname(__FILE__)); +use Test::DH; -if ($< == 0) { - $rootcmd = ''; -} -else { - system("fakeroot true 2>/dev/null"); - $rootcmd = $? ? undef : 'fakeroot'; -} +our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( + debian/changelog + debian/control + debian/docfile + debian/copyright +)); -if (not defined($rootcmd)) { +if (uid_0_test_is_ok()) { + plan(tests => 5); +} else { plan skip_all => 'fakeroot required'; } -else { - plan(tests => 18); -} -# Drop DEB_BUILD_PROFILES and DEB_BUILD_OPTIONS so they don't interfere -delete($ENV{DEB_BUILD_PROFILES}); -delete($ENV{DEB_BUILD_OPTIONS}); - -system("rm -rf debian/foo debian/bar debian/baz"); +my $NEEDS_ROOT = { 'needs_root' => 1 }; +my $NEEDS_ROOT_NODOC_PROFILE = { + 'needs_root' => 1, + 'env' => { + 'DEB_BUILD_PROFILES' => 'nodoc', + }, +}; 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"); +each_compat_subtest { + ok(run_dh_tool($NEEDS_ROOT, 'dh_installdocs', '-pbar', $doc)); + ok(-e "debian/bar/usr/share/doc/bar/docfile"); + remove_tree(qw(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"); +each_compat_subtest { + #regression in debhelper 9.20160702 (#830309) + ok(run_dh_tool($NEEDS_ROOT, 'dh_installdocs', '-pbaz', '--link-doc=foo', $doc)); -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"); + 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"); + remove_tree(qw(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"); +each_compat_subtest { + ok(run_dh_tool($NEEDS_ROOT, 'dh_installdocs', '-pfoo', '--link-doc=bar', $doc)); -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"); + 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"); + remove_tree(qw(debian/foo debian/bar debian/baz)); +}; # ... and with nodoc -# docs are ignored, but copyright file is still there -system("DEB_BUILD_PROFILES=nodoc $rootcmd $TOPDIR/dh_installdocs -pbar $doc"); -ok(!-e "debian/bar/usr/share/doc/bar/docfile"); -ok(!-e "debian/bar/usr/share/doc/bar/copyright"); -system("rm -rf debian/foo debian/bar debian/baz"); - -# docs are ignored, but symlinked doc dir is still there -system("DEB_BUILD_PROFILES=nodoc 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"); +each_compat_subtest { + # docs are ignored, but copyright file is still there + ok(run_dh_tool($NEEDS_ROOT_NODOC_PROFILE, 'dh_installdocs', $doc)); + for my $pkg (qw(foo bar baz)) { + ok(! -e "debian/$pkg/usr/share/doc/$pkg/docfile"); + ok(-e "debian/$pkg/usr/share/doc/$pkg/copyright"); + } + remove_tree(qw(debian/foo debian/bar debian/baz)); +}; + +each_compat_subtest { + # docs are ignored, but symlinked doc dir is still there + ok(run_dh_tool($NEEDS_ROOT_NODOC_PROFILE, '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"); + remove_tree(qw(debian/foo debian/bar debian/baz)); +}; # Local Variables: # indent-tabs-mode: t |