From ff2177c68252c80e75c2e0fbc4d40e8193d4cb36 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 14 May 2019 11:56:46 +0000 Subject: Create package for test-related code. --- Makefile | 2 +- T.pm | 27 +++++++++++++++++++++++++++ debian/changelog | 1 + t/924903.t | 25 +------------------------ 4 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 T.pm diff --git a/Makefile b/Makefile index e39c248..46acb19 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ all: check: - prove + prove -I. .PHONY: check diff --git a/T.pm b/T.pm new file mode 100644 index 0000000..4178fd8 --- /dev/null +++ b/T.pm @@ -0,0 +1,27 @@ +package T; +use strict; +use warnings; +use Cwd; +use Test::More; +use File::Copy::Recursive qw(dircopy); +use File::Path qw(remove_tree); +use Exporter; +our @ISA = qw(Exporter); +our @EXPORT = qw(system_ok); + +my $root = Cwd::cwd; +$ENV{PATH} = "$root:$ENV{PATH}"; +$ENV{DH_AUTOSCRIPTDIR} = $root; + +die '$0 does not match expected format' + unless ($0 =~ m#t/([0-9]+)\.t#); +my $number = $1; +my $srcdir = (-d "t/base/${number}") ? "t/base/${number}" : "t/base/default"; +my $testdir = "t/${number}"; +remove_tree($testdir); +dircopy($srcdir, $testdir); +chdir($testdir); + +sub system_ok { ok(system(@_) == 0, "external command @_");} + +1; diff --git a/debian/changelog b/debian/changelog index 9cce49c..0147167 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ dh-runit (2.8.11) UNRELEASED; urgency=medium * Make build system respect `nocheck' option. + * Create package for test-related code. -- Dmitry Bogatov Wed, 20 Mar 2019 13:22:22 +0000 diff --git a/t/924903.t b/t/924903.t index fa70834..710ea39 100644 --- a/t/924903.t +++ b/t/924903.t @@ -2,31 +2,8 @@ use strict; use warnings; use Test::More tests => 3; -use File::Path qw(remove_tree); -use File::Copy::Recursive qw(dircopy); use File::stat; -use Cwd; - -my $root = Cwd::cwd; -$ENV{PATH} = "$root:$ENV{PATH}"; -$ENV{DH_AUTOSCRIPTDIR} = $root; - -sub prepare_source_package { - die '$0 does not match expected format' - unless ($0 =~ m#t/([0-9]+)\.t#); - my $number = $1; - my $srcdir = (-d "t/base/${number}") ? "t/base/${number}" : "t/base/default"; - my $testdir = "t/${number}"; - dircopy($srcdir, $testdir); - chdir($testdir); - return $testdir; -} - -sub system_ok { - ok(system(@_) == 0, "external command @_"); -} - -prepare_source_package(); +use T; system_ok('dh_runit', 'debian/test.runscript', 'name=test'); my $path = 'debian/dh-runit-test/var/lib/runit/supervise/test'; -- cgit v1.2.3