summaryrefslogtreecommitdiff
path: root/scripts/t
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2017-01-23 04:45:19 +0100
committerGuillem Jover <guillem@debian.org>2017-01-25 04:02:40 +0100
commit2f05b55f031371458f6903fae4bfebacc555bd07 (patch)
treeac32cba850d37d67d34631bae5255c97d26c9b66 /scripts/t
parent24212e60a762bfc1d71a782646fb1fbf830bcfaf (diff)
downloaddpkg-2f05b55f031371458f6903fae4bfebacc555bd07.tar.gz
test: Refactor unit test data path into test_get_data_path()
Diffstat (limited to 'scripts/t')
-rw-r--r--scripts/t/Dpkg_Changelog.t4
-rw-r--r--scripts/t/Dpkg_Changelog_Ubuntu.t8
-rw-r--r--scripts/t/Dpkg_Checksums.t4
-rw-r--r--scripts/t/Dpkg_Conf.t4
-rw-r--r--scripts/t/Dpkg_Control.t5
-rw-r--r--scripts/t/Dpkg_Control_Tests.t4
-rw-r--r--scripts/t/Dpkg_Dist_Files.t4
-rw-r--r--scripts/t/Dpkg_Shlibs.t7
-rw-r--r--scripts/t/Dpkg_Source_Patch.t4
-rw-r--r--scripts/t/Dpkg_Source_Quilt.t4
-rw-r--r--scripts/t/Dpkg_Substvars.t4
11 files changed, 27 insertions, 25 deletions
diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t
index e64ec878b..7535e24de 100644
--- a/scripts/t/Dpkg_Changelog.t
+++ b/scripts/t/Dpkg_Changelog.t
@@ -17,6 +17,7 @@ use strict;
use warnings;
use Test::More tests => 94;
+use Test::Dpkg qw(:paths);
use File::Basename;
@@ -28,8 +29,7 @@ BEGIN {
use_ok('Dpkg::Vendor', qw(get_current_vendor));
};
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Changelog';
+my $datadir = test_get_data_path('t/Dpkg_Changelog');
my $vendor = get_current_vendor();
diff --git a/scripts/t/Dpkg_Changelog_Ubuntu.t b/scripts/t/Dpkg_Changelog_Ubuntu.t
index b2e3783b1..1cd622d70 100644
--- a/scripts/t/Dpkg_Changelog_Ubuntu.t
+++ b/scripts/t/Dpkg_Changelog_Ubuntu.t
@@ -16,6 +16,10 @@
use strict;
use warnings;
+use Test::Dpkg qw(:paths);
+
$ENV{DEB_VENDOR} = 'Ubuntu';
-my $srcdir = $ENV{srcdir} || '.';
-do "$srcdir/t/Dpkg_Changelog.t";
+
+my $datafile = test_get_data_path('t/Dpkg_Changelog.t');
+
+do "$datafile";
diff --git a/scripts/t/Dpkg_Checksums.t b/scripts/t/Dpkg_Checksums.t
index f15720261..6c7dc80a8 100644
--- a/scripts/t/Dpkg_Checksums.t
+++ b/scripts/t/Dpkg_Checksums.t
@@ -17,13 +17,13 @@ use strict;
use warnings;
use Test::More tests => 44;
+use Test::Dpkg qw(:paths);
BEGIN {
use_ok('Dpkg::Checksums');
}
-my $srcdir = $ENV{srcdir} // '.';
-my $datadir = $srcdir . '/t/Dpkg_Checksums';
+my $datadir = test_get_data_path('t/Dpkg_Checksums');
my @data = (
{
diff --git a/scripts/t/Dpkg_Conf.t b/scripts/t/Dpkg_Conf.t
index c6f051069..2e55e3d59 100644
--- a/scripts/t/Dpkg_Conf.t
+++ b/scripts/t/Dpkg_Conf.t
@@ -17,13 +17,13 @@ use strict;
use warnings;
use Test::More tests => 9;
+use Test::Dpkg qw(:paths);
BEGIN {
use_ok('Dpkg::Conf');
}
-my $srcdir = $ENV{srcdir} // '.';
-my $datadir = $srcdir . '/t/Dpkg_Conf';
+my $datadir = test_get_data_path('t/Dpkg_Conf');
my ($conf, $count, @opts);
diff --git a/scripts/t/Dpkg_Control.t b/scripts/t/Dpkg_Control.t
index 5fbb8783b..40b9d33bf 100644
--- a/scripts/t/Dpkg_Control.t
+++ b/scripts/t/Dpkg_Control.t
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
BEGIN {
test_needs_module('IO::String');
@@ -28,8 +28,7 @@ BEGIN {
use_ok('Dpkg::Control::Info');
}
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Control';
+my $datadir = test_get_data_path('t/Dpkg_Control');
sub parse_dsc {
my $path = shift;
diff --git a/scripts/t/Dpkg_Control_Tests.t b/scripts/t/Dpkg_Control_Tests.t
index b9905bacf..9c14a2e4e 100644
--- a/scripts/t/Dpkg_Control_Tests.t
+++ b/scripts/t/Dpkg_Control_Tests.t
@@ -17,13 +17,13 @@ use strict;
use warnings;
use Test::More tests => 5;
+use Test::Dpkg qw(:paths);
BEGIN {
use_ok('Dpkg::Control::Tests');
}
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Control_Tests';
+my $datadir = test_get_data_path('t/Dpkg_Control_Tests');
sub parse_tests {
my $path = shift;
diff --git a/scripts/t/Dpkg_Dist_Files.t b/scripts/t/Dpkg_Dist_Files.t
index 4dccffe7f..d43c2245e 100644
--- a/scripts/t/Dpkg_Dist_Files.t
+++ b/scripts/t/Dpkg_Dist_Files.t
@@ -17,11 +17,11 @@ use strict;
use warnings;
use Test::More tests => 26;
+use Test::Dpkg qw(:paths);
use_ok('Dpkg::Dist::Files');
-my $srcdir = $ENV{srcdir} // '.';
-my $datadir = $srcdir . '/t/Dpkg_Dist_Files';
+my $datadir = test_get_data_path('t/Dpkg_Dist_Files');
my $expected;
my %expected = (
diff --git a/scripts/t/Dpkg_Shlibs.t b/scripts/t/Dpkg_Shlibs.t
index 2e68f74a4..578e4e4a3 100644
--- a/scripts/t/Dpkg_Shlibs.t
+++ b/scripts/t/Dpkg_Shlibs.t
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
use Cwd;
@@ -33,8 +33,7 @@ my $tmp;
my @tmp;
my %tmp;
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Shlibs';
+my $datadir = test_get_data_path('t/Dpkg_Shlibs');
my @librarypaths;
@@ -58,7 +57,7 @@ Dpkg::Shlibs::blank_library_paths();
# is usually a relative path, so let's temporarily switch directory.
# XXX: An alternative would be to make parse_ldso_conf relative path aware.
my $cwd = cwd();
-chdir($srcdir);
+test_needs_srcdir_switch();
Dpkg::Shlibs::parse_ldso_conf('t/Dpkg_Shlibs/ld.so.conf');
chdir($cwd);
diff --git a/scripts/t/Dpkg_Source_Patch.t b/scripts/t/Dpkg_Source_Patch.t
index 258a9aa67..8f382f546 100644
--- a/scripts/t/Dpkg_Source_Patch.t
+++ b/scripts/t/Dpkg_Source_Patch.t
@@ -17,6 +17,7 @@ use strict;
use warnings;
use Test::More tests => 9;
+use Test::Dpkg qw(:paths);
use File::Path qw(make_path);
@@ -24,8 +25,7 @@ BEGIN {
use_ok('Dpkg::Source::Patch');
}
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Source_Patch';
+my $datadir = test_get_data_path('t/Dpkg_Source_Patch');
my $tmpdir = 't.tmp/Dpkg_Source_Patch';
sub test_patch_escape {
diff --git a/scripts/t/Dpkg_Source_Quilt.t b/scripts/t/Dpkg_Source_Quilt.t
index f8d82e081..af0071dea 100644
--- a/scripts/t/Dpkg_Source_Quilt.t
+++ b/scripts/t/Dpkg_Source_Quilt.t
@@ -17,13 +17,13 @@ use strict;
use warnings;
use Test::More tests => 2;
+use Test::Dpkg qw(:paths);
BEGIN {
use_ok('Dpkg::Source::Quilt');
}
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Source_Quilt';
+my $datadir = test_get_data_path('t/Dpkg_Source_Quilt');
my $quilt;
my (@series_got, @series_exp);
diff --git a/scripts/t/Dpkg_Substvars.t b/scripts/t/Dpkg_Substvars.t
index 0f6c3ce79..ded25ddc8 100644
--- a/scripts/t/Dpkg_Substvars.t
+++ b/scripts/t/Dpkg_Substvars.t
@@ -17,14 +17,14 @@ use strict;
use warnings;
use Test::More tests => 37;
+use Test::Dpkg qw(:paths);
use Dpkg ();
use Dpkg::Arch qw(get_host_arch);
use_ok('Dpkg::Substvars');
-my $srcdir = $ENV{srcdir} || '.';
-my $datadir = $srcdir . '/t/Dpkg_Substvars';
+my $datadir = test_get_data_path('t/Dpkg_Substvars');
my $expected;