summaryrefslogtreecommitdiff
path: root/t/maintscript.t
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-11-19 13:00:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-11-19 13:00:50 +0300
commit0f55f1989c5eef00d91f7ae8e12f781e52f2e628 (patch)
treebfe0eb53e99fd38bc316f0642656237fd9f86ba7 /t/maintscript.t
parent04c923d15dbe45268d71beb9f1ac012bb6dcc9ec (diff)
parent1a52f701f3c9fb3d1dc18461e06176dc046b0f42 (diff)
downloaddebhelper-0f55f1989c5eef00d91f7ae8e12f781e52f2e628.tar.gz
Merge https://anonscm.debian.org/git/debhelper/debhelper
Diffstat (limited to 't/maintscript.t')
-rwxr-xr-xt/maintscript.t52
1 files changed, 32 insertions, 20 deletions
diff --git a/t/maintscript.t b/t/maintscript.t
index e15daea3..a69c99c7 100755
--- a/t/maintscript.t
+++ b/t/maintscript.t
@@ -1,28 +1,40 @@
#!/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 qw(!dirname);
+
+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
-# tab-width: 4
-# cperl-indent-level: 4
-# End: