summaryrefslogtreecommitdiff
path: root/scripts/t
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2017-10-29 18:40:54 +0100
committerGuillem Jover <guillem@debian.org>2018-01-16 10:55:30 +0100
commit876855ff96f6dd72cbb92fa57bc316576f585737 (patch)
treeb82cda0a0cf5df51976aa3815d7c428a09bed6d7 /scripts/t
parent33c866433dd4b186aae970e05c639b52ad5e7ece (diff)
downloaddpkg-876855ff96f6dd72cbb92fa57bc316576f585737.tar.gz
test: Infer automatically the unit test temp directory
Add new test_get_temp_path() function, and replace all hardcoded settings of the temporary directory and its creation.
Diffstat (limited to 'scripts/t')
-rw-r--r--scripts/t/Dpkg_Compression.t4
-rw-r--r--scripts/t/Dpkg_OpenPGP.t4
-rw-r--r--scripts/t/Dpkg_Path.t4
-rw-r--r--scripts/t/Dpkg_Source_Patch.t2
-rw-r--r--scripts/t/dpkg_buildpackage.t6
-rw-r--r--scripts/t/dpkg_source.t6
6 files changed, 10 insertions, 16 deletions
diff --git a/scripts/t/Dpkg_Compression.t b/scripts/t/Dpkg_Compression.t
index 3a2be1107..3babe5fca 100644
--- a/scripts/t/Dpkg_Compression.t
+++ b/scripts/t/Dpkg_Compression.t
@@ -17,12 +17,12 @@ use strict;
use warnings;
use Test::More tests => 13;
+use Test::Dpkg qw(:paths);
use_ok('Dpkg::Compression');
use_ok('Dpkg::Compression::FileHandle');
-my $tmpdir = 't.tmp/Dpkg_Compression';
-mkdir $tmpdir;
+my $tmpdir = test_get_temp_path();
my @lines = ("One\n", "Two\n", "Three\n");
my $fh;
diff --git a/scripts/t/Dpkg_OpenPGP.t b/scripts/t/Dpkg_OpenPGP.t
index 0d2e4afef..b39613149 100644
--- a/scripts/t/Dpkg_OpenPGP.t
+++ b/scripts/t/Dpkg_OpenPGP.t
@@ -32,9 +32,7 @@ use_ok('Dpkg::OpenPGP');
report_options(quiet_warnings => 1);
my $datadir = test_get_data_path();
-my $tmpdir = 't.tmp/Dpkg_OpenPGP';
-
-mkdir $tmpdir;
+my $tmpdir = test_get_temp_path();
openpgp_sig_to_asc("$datadir/package_1.0.orig.tar.sig",
"$tmpdir/package_1.0.orig.tar.sig2asc");
diff --git a/scripts/t/Dpkg_Path.t b/scripts/t/Dpkg_Path.t
index deb63bab7..fbf883d64 100644
--- a/scripts/t/Dpkg_Path.t
+++ b/scripts/t/Dpkg_Path.t
@@ -17,14 +17,14 @@ use strict;
use warnings;
use Test::More tests => 16;
+use Test::Dpkg qw(:paths);
use_ok('Dpkg::Path', 'canonpath', 'resolve_symlink',
'check_files_are_the_same', 'get_pkg_root_dir',
'guess_pkg_root_dir', 'relative_to_pkg_root');
-my $tmpdir = 't.tmp/Dpkg_Path';
+my $tmpdir = test_get_temp_path();
-mkdir $tmpdir;
mkdir "$tmpdir/a";
mkdir "$tmpdir/a/b";
mkdir "$tmpdir/a/b/c";
diff --git a/scripts/t/Dpkg_Source_Patch.t b/scripts/t/Dpkg_Source_Patch.t
index d0e167dbd..f50f15be2 100644
--- a/scripts/t/Dpkg_Source_Patch.t
+++ b/scripts/t/Dpkg_Source_Patch.t
@@ -26,7 +26,7 @@ BEGIN {
}
my $datadir = test_get_data_path();
-my $tmpdir = 't.tmp/Dpkg_Source_Patch';
+my $tmpdir = test_get_temp_path();
sub test_patch_escape {
my ($name, $symlink, $patchname, $desc) = @_;
diff --git a/scripts/t/dpkg_buildpackage.t b/scripts/t/dpkg_buildpackage.t
index 2b4345539..dd4f67a6f 100644
--- a/scripts/t/dpkg_buildpackage.t
+++ b/scripts/t/dpkg_buildpackage.t
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Test::More;
-use Test::Dpkg qw(:needs test_neutralize_checksums);
+use Test::Dpkg qw(:needs :paths test_neutralize_checksums);
use File::Spec::Functions qw(rel2abs);
use File::Compare;
@@ -34,7 +34,7 @@ plan tests => 12;
my $srcdir = rel2abs($ENV{srcdir} || '.');
my $datadir = "$srcdir/t/dpkg_buildpackage";
-my $tmpdir = 't.tmp/dpkg_buildpackage';
+my $tmpdir = test_get_temp_path();
$ENV{$_} = rel2abs($ENV{$_}) foreach qw(DPKG_DATADIR DPKG_ORIGINS_DIR);
@@ -48,8 +48,6 @@ delete $ENV{SOURCE_DATE_EPOCH};
# Delete other variables that can affect the tests.
delete $ENV{$_} foreach grep { m/^DEB_/ } keys %ENV;
-make_path($tmpdir);
-
chdir $tmpdir;
my $tmpl_format = <<'TMPL_FORMAT';
diff --git a/scripts/t/dpkg_source.t b/scripts/t/dpkg_source.t
index cdbedceb3..a0c343846 100644
--- a/scripts/t/dpkg_source.t
+++ b/scripts/t/dpkg_source.t
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Test::More tests => 8;
-use Test::Dpkg qw(test_neutralize_checksums);
+use Test::Dpkg qw(:paths test_neutralize_checksums);
use File::Spec::Functions qw(rel2abs);
use File::Compare;
@@ -28,15 +28,13 @@ use Dpkg::Substvars;
my $srcdir = rel2abs($ENV{srcdir} || '.');
my $datadir = "$srcdir/t/dpkg_source";
-my $tmpdir = 't.tmp/dpkg_source';
+my $tmpdir = test_get_temp_path();
$ENV{$_} = rel2abs($ENV{$_}) foreach qw(DPKG_DATADIR DPKG_ORIGINS_DIR);
# Delete variables that can affect the tests.
delete $ENV{SOURCE_DATE_EPOCH};
-make_path($tmpdir);
-
chdir $tmpdir;
my $tmpl_format = <<'TMPL_FORMAT';