[debhelper-devel] [debhelper] 07/30: maintscript.t: Convert to Test::DH

Niels Thykier nthykier at moszumanska.debian.org
Mon Jul 3 14:40:36 UTC 2017


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

nthykier pushed a commit to branch master
in repository debhelper.

commit c725e8a7d297c0334402e197831b59b7575e99e1
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jul 2 10:49:46 2017 +0000

    maintscript.t: Convert to Test::DH
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 t/maintscript.t | 47 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/t/maintscript.t b/t/maintscript.t
index e15daea..f033a50 100755
--- a/t/maintscript.t
+++ b/t/maintscript.t
@@ -1,25 +1,42 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use Test;
-plan(tests => 8);
+use Test::More;
 
-system("mkdir -p t/tmp/debian");
-system("cp debian/control t/tmp/debian");
-open(OUT, ">", "t/tmp/debian/maintscript") || die "$!";
-print OUT <<EOF;
+use File::Path qw(remove_tree);
+use File::Basename qw(dirname);
+use lib dirname(__FILE__);
+use Test::DH;
+use Debian::Debhelper::Dh_Lib;
+
+if (uid_0_test_is_ok()) {
+	plan(tests => 1);
+} else {
+	plan skip_all => 'fakeroot required';
+}
+
+each_compat_up_to_and_incl_subtest(10, sub {
+	my @scripts = qw{postinst preinst prerm postrm};
+	my $file = 'debian/maintscript';
+
+	remove_tree('debian/debhelper', 'debian/tmp');
+	rm_files(@scripts, $file);
+
+	open(my $fd, ">", $file) || die("open($file): $!");
+	print {$fd} <<EOF;
 rm_conffile /etc/1
 mv_conffile /etc/2 /etc/3 1.0-1
 EOF
-close OUT;
-system("echo 10 >> t/tmp/debian/compat");
-system("cd t/tmp && fakeroot ../../dh_installdeb");
-for my $script (qw{postinst preinst prerm postrm}) {
-	my @output=`cat t/tmp/debian/debhelper.$script.debhelper`;
-	ok(grep { m{^dpkg-maintscript-helper rm_conffile /etc/1 -- "\$\@"$} } @output);
-	ok(grep { m{^dpkg-maintscript-helper mv_conffile /etc/2 /etc/3 1\.0-1 -- "\$\@"$} } @output);
-}
-system("rm -rf t/tmp");
+	close($fd) or die("close($file): $!\n");
+
+	run_dh_tool( { 'needs_root' => 1 }, 'dh_installdeb');
+
+	for my $script (@scripts) {
+		my @output=`cat debian/debhelper.$script.debhelper`;
+		ok(grep { m{^dpkg-maintscript-helper rm_conffile /etc/1 -- "\$\@"$} } @output);
+		ok(grep { m{^dpkg-maintscript-helper mv_conffile /etc/2 /etc/3 1\.0-1 -- "\$\@"$} } @output);
+	}
+});
 
 # Local Variables:
 # indent-tabs-mode: t

-- 
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