From c2cb8f95a03c311972b110fc1fb6029c46446cad Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Sun, 11 Aug 2024 09:57:58 -0400 Subject: [PATCH] Don't retain 'storable-testfile-*' after completion of testing When run in Perl core, make test was leaving 109 files in /tmp. The two changes in this patch cleaned up 103 and 6 files, respectively. Account for test failure on Windows. The 'unlink' statement at line 284 in blead dates from 2002 and was not altered during recent refactoring of Storable. CI testing suggests it is now superflous and can be removed without causing test failures on Linux or Windows. For: GH #22502 --- dist/Storable/t/lib/STTestLib.pm | 4 ++-- dist/Storable/t/malice.t | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dist/Storable/t/lib/STTestLib.pm b/dist/Storable/t/lib/STTestLib.pm index 626f59e06bb5..a3703345aafa 100644 --- a/dist/Storable/t/lib/STTestLib.pm +++ b/dist/Storable/t/lib/STTestLib.pm @@ -22,7 +22,7 @@ sub slurp { sub write_and_retrieve { my $data = shift; - my ($fh, $filename) = tempfile('storable-testfile-XXXXX', TMPDIR => 1); + my ($fh, $filename) = tempfile('storable-testfile-XXXXX', TMPDIR => 1, UNLINK => 1); binmode $fh; print $fh $data or die "Can't print to '$filename': $!"; close $fh or die "Can't close '$filename': $!"; @@ -32,7 +32,7 @@ sub write_and_retrieve { sub tempfilename { local $^W; - my (undef, $file) = tempfile('storable-testfile-XXXXX', TMPDIR => 1, UNLINK => 1, OPEN => 0); + my (undef, $file) = tempfile('storable-testfile-XXXXX', TMPDIR => 1, UNLINK => 1); return $file; } diff --git a/dist/Storable/t/malice.t b/dist/Storable/t/malice.t index ef1a475cff7d..f72e45f385ee 100644 --- a/dist/Storable/t/malice.t +++ b/dist/Storable/t/malice.t @@ -280,9 +280,6 @@ test_things($contents, \&write_and_retrieve, 'file'); my $stored = freeze \%hash; test_things($stored, sub { eval { thaw $_[0] } }, 'string'); -# Network order. -unlink $file or die "Can't unlink '$file': $!"; - ok (defined nstore(\%hash, $file), "nstore() returned defined value"); $expected = 20 + length ($file_magic_str) + $network_magic + $fancy;