[debhelper-devel] [debhelper] 08/30: dh_compress.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 04b1094a206b8ab71898a64424928de7d08656a6
Author: Niels Thykier <niels at thykier.net>
Date: Sun Jul 2 10:56:23 2017 +0000
dh_compress.t: Convert to Test::DH
Signed-off-by: Niels Thykier <niels at thykier.net>
---
t/dh_compress.t | 88 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 43 insertions(+), 45 deletions(-)
diff --git a/t/dh_compress.t b/t/dh_compress.t
index dcd7f90..d3987b5 100755
--- a/t/dh_compress.t
+++ b/t/dh_compress.t
@@ -2,62 +2,64 @@
use strict;
use warnings;
+
use File::Basename qw(dirname);
-use lib dirname(__FILE__).'/..';
+use lib dirname(__FILE__);
+use Test::DH;
+
use File::Path qw(make_path remove_tree);
use Test::More;
+use Debian::Debhelper::Dh_Lib;
-chdir dirname(__FILE__).'/..';
-$ENV{PERL5OPT} = '-I'.dirname(__FILE__).'/..';
my $PREFIX = 'debian/debhelper/usr/share/doc/debhelper';
-# we are testing compressing doc txt files
-# foo.txt is 2k and bar.txt is 5k
-mk_test_dir();
+plan tests => 1;
-# default operation, bar.txt becomes bar.txt.gz and foo.txt is unchanged
-dh_compress();
+each_compat_subtest {
+ # we are testing compressing doc txt files
+ # foo.txt is 2k and bar.txt is 5k
+ mk_test_dir();
-is_deeply(
- [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
- [qw|bar.txt.gz foo.txt|],
- '5k txt doc compressed, 2k txt doc not compressed'
-);
+ # default operation, bar.txt becomes bar.txt.gz and foo.txt is
+ # unchanged
+ ok(run_dh_tool('dh_compress'));
-mk_test_dir();
+ is_deeply(
+ [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
+ [qw|bar.txt.gz foo.txt|],
+ '5k txt doc compressed, 2k txt doc not compressed'
+ );
-# now if I want to pass both on the command line to dh_compress, it should
-# compress both
-dh_compress(qw|
- --
- usr/share/doc/debhelper/foo.txt
- usr/share/doc/debhelper/bar.txt
-|);
+ mk_test_dir();
-is_deeply(
- [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
- [qw|bar.txt.gz foo.txt.gz|],
- 'both 5k and 2k txt docs compressed'
-);
+ # now if I want to pass both on the command line to dh_compress,
+ # it should compress both
+ ok(run_dh_tool('dh_compress', '--',
+ 'usr/share/doc/debhelper/foo.txt',
+ 'usr/share/doc/debhelper/bar.txt'));
-mk_test_dir();
+ is_deeply(
+ [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
+ [qw|bar.txt.gz foo.txt.gz|],
+ 'both 5k and 2k txt docs compressed'
+ );
-# absolute paths should also work
-dh_compress(qw|
- --
- /usr/share/doc/debhelper/foo.txt
- /usr/share/doc/debhelper/bar.txt
-|);
+ mk_test_dir();
-is_deeply(
- [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
- [qw|bar.txt.gz foo.txt.gz|],
- 'both 5k and 2k txt docs compressed by absolute path args'
-);
+ # absolute paths should also work
+ ok(run_dh_tool('dh_compress', '--',
+ '/usr/share/doc/debhelper/foo.txt',
+ '/usr/share/doc/debhelper/bar.txt'));
-rm_test_dir();
+ is_deeply(
+ [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
+ [qw|bar.txt.gz foo.txt.gz|],
+ 'both 5k and 2k txt docs compressed by absolute path args'
+ );
+
+ rm_test_dir();
+};
-done_testing;
sub mk_test_dir {
rm_test_dir();
@@ -84,10 +86,6 @@ sub mk_test_dir {
sub rm_test_dir {
remove_tree('debian/debhelper');
- unlink 'debian/debhelper.debhelper.log'; # ignore error, it may not exist
+ rm_files('debian/debhelper.debhelper.log');
}
-sub dh_compress {
- system('./dh_compress', @_) == 0
- or fail("Could not run ./dh_compress @_: $?");
-}
--
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