Skip Menu |

This queue is for tickets about the Test-Trap CPAN distribution.

Report information
The Basics
Id: 61776
Status: resolved
Priority: 0/
Queue: Test-Trap

People
Owner: ebhanssen [...] allverden.no
Requestors: Ian.Goodacre [...] xtra.co.nz
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: v0.2.1
Fixed in: (no value)



Subject: removal of temporary files
After the trap has sprung, temporary files are left behind. They will be removed by File::Temp when the process terminates but in the mean time they persist. This is problematic in test scripts attempting to test that temporary files are not left behind. This is easily fixed by unlinking $file in the Teardown sub after closing $fh. With this change, after the trap is sprung, the temporary files are gone. Of course, I am assuming the file isn't used after the Teardown sub has closed the file handle.
From: Ian.Goodacre [...] xtra.co.nz
I patched Test::Trap::Builder::TempFile.pm as follows: --- TempFile.pm.orig 2010-09-30 18:48:45.000000000 +1300 +++ TempFile.pm 2010-09-30 09:35:28.000000000 +1300 @@ -20,6 +20,7 @@ local $/; $self->{$name} .= <$fh>; close $fh; + unlink $file; }; binmode $fh; # superfluos? local *$globref;
On Wed Sep 29 16:41:16 2010, iang wrote: Show quoted text
> After the trap has sprung, temporary files are left behind. They will be > removed by File::Temp when the process terminates but in the mean time > they persist. This is problematic in test scripts attempting to test > that temporary files are not left behind. > > This is easily fixed by unlinking $file in the Teardown sub after > closing $fh. With this change, after the trap is sprung, the temporary > files are gone. Of course, I am assuming the file isn't used after the > Teardown sub has closed the file handle.
Thank you; that's a sensible request, and your patch is a good one. (I've patched Test::Trap::Builder::SystemSafe.pm analogously.) Sorry I have been late in responding; this seems to have fallen through the cracks for me – I only found it as I was rounding up tagalongs for an upcoming bugfix release. (Just need a regression test for that. And on that thought, I probably should write one for this as well ...) -- Eirik Berg Hanssen, ebhanssen@cpan.org Just this .sig then nothing more
I have at long last made a new release, incorporating this fix. Sorry it took so long.