diff options
author | Guillem Jover <guillem@debian.org> | 2014-09-25 18:42:49 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-10-06 02:08:03 +0200 |
commit | 386e46306f1f6dbb84296f9be1379de10b1cc535 (patch) | |
tree | 24b4885182be49b8bb5021ba5f8385c548caf5cf /scripts | |
parent | 49a77f01c54c422637dfdec6bf8a6d3203debc38 (diff) | |
download | dpkg-386e46306f1f6dbb84296f9be1379de10b1cc535.tar.gz |
scripts/t: Make sure temporary files are always cleaned up
If the test suite is interrupted or it fails in the middle, the
temporary files will not be unlinked. Switch to use the native
File::Temp support for removal.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/t/Dpkg_IPC.t | 7 | ||||
-rw-r--r-- | scripts/t/merge_changelogs.t | 9 |
2 files changed, 6 insertions, 10 deletions
diff --git a/scripts/t/Dpkg_IPC.t b/scripts/t/Dpkg_IPC.t index 3620ff6c3..d312f319d 100644 --- a/scripts/t/Dpkg_IPC.t +++ b/scripts/t/Dpkg_IPC.t @@ -23,8 +23,8 @@ use_ok('Dpkg::IPC'); $/ = undef; -my ($tmp1_fh, $tmp1_name) = tempfile; -my ($tmp2_fh, $tmp2_name) = tempfile; +my ($tmp1_fh, $tmp1_name) = tempfile(UNLINK => 1); +my ($tmp2_fh, $tmp2_name) = tempfile(UNLINK => 1); my $tmp_fh; my $string1 = "foo\nbar\n"; @@ -79,6 +79,3 @@ eval { timeout => 5); }; ok($@, 'fails on timeout'); - -unlink($tmp1_name); -unlink($tmp2_name); diff --git a/scripts/t/merge_changelogs.t b/scripts/t/merge_changelogs.t index 5e7b40c62..1e8c43e37 100644 --- a/scripts/t/merge_changelogs.t +++ b/scripts/t/merge_changelogs.t @@ -21,7 +21,7 @@ use Test::More tests => 3; use Dpkg::IPC; use File::Spec; use File::Compare; -use File::Temp qw(tempfile); +use File::Temp; my $srcdir = $ENV{srcdir} || '.'; my $datadir = "$srcdir/t/merge_changelogs"; @@ -29,16 +29,15 @@ my $datadir = "$srcdir/t/merge_changelogs"; my $res; sub test_merge { my ($expected_file, @options) = @_; - my ($fh, $filename) = tempfile(); + my $fh = File::Temp->new(); spawn(exec => ["$srcdir/dpkg-mergechangelogs.pl", @options], to_handle => $fh, error_to_file => '/dev/null', wait_child => 1, nocheck => 1); - my $res = compare($expected_file, $filename); + my $res = compare($expected_file, $fh->filename); if ($res) { - system("diff -u $expected_file $filename >&2"); + system("diff -u $expected_file $fh->filename >&2"); } ok($res == 0, "merged changelog matches expected one ($expected_file)"); - unlink($filename); } my $has_alg_merge = 1; |