Skip Menu |
 

This queue is for tickets about the bioperl CPAN distribution.

Report information
The Basics
Id: 48813
Status: resolved
Priority: 0/
Queue: bioperl

People
Owner: Nobody in particular
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.6.0
Fixed in: (no value)



Subject: Win32 compatibility PATCH
Download (untitled) / with headers
text/plain 1016b
Hi, please find enclosed simple patch that fixes a failing test t/SeqFeature/SeqFeatCollection.t when installing Bio::Perl on Win32/strawberry. The problem was that File::Temp->new() (called in sub test_output_file) returns an open filehandle to temporary file and it is still open even after return from sub test_output_file. You later in the code unlink this tempfile; however Windows do not allow unlinking an open filehandle - and it was the cause of the problems. So I simply close the temporary filehandle and left the created tempfile on the filesystem (you are handling keeping/deleting these files yourself). -- kmx --- BioPerl-1.6.0/Bio/Root/Test.pm +++ BioPerl-1.6.0patched/Bio/Root/Test.pm @@ -299,10 +299,12 @@ sub test_output_file { die "test_output_file takes no args\n" if @_; - my $tmp = File::Temp->new(); + my $tmp = File::Temp->new(UNLINK => 0); push(@TEMP_FILES, $tmp); + my $fname = $tmp->filename; + close($tmp); - return $tmp->filename; + return $fname; }
Download (untitled) / with headers
text/plain 1.5k
On Tue Aug 18 15:08:49 2009, KMX wrote: Show quoted text
> Hi, > > please find enclosed simple patch that fixes a failing test > t/SeqFeature/SeqFeatCollection.t when installing Bio::Perl on > Win32/strawberry. > > The problem was that File::Temp->new() (called in sub test_output_file) > returns an open filehandle to temporary file and it is still open even > after return from sub test_output_file. You later in the code unlink > this tempfile; however Windows do not allow unlinking an open filehandle > - and it was the cause of the problems. > > So I simply close the temporary filehandle and left the created tempfile > on the filesystem (you are handling keeping/deleting these files yourself). > > -- > kmx > > --- BioPerl-1.6.0/Bio/Root/Test.pm > +++ BioPerl-1.6.0patched/Bio/Root/Test.pm > @@ -299,10 +299,12 @@ > sub test_output_file { > die "test_output_file takes no args\n" if @_; > > - my $tmp = File::Temp->new(); > + my $tmp = File::Temp->new(UNLINK => 0); > push(@TEMP_FILES, $tmp); > + my $fname = $tmp->filename; > + close($tmp); > > - return $tmp->filename; > + return $fname; > }
The problem is we have tons of temp files made using this method, so leaving them present on the user's system is untenable. However, the above works if you close the filehandle but allow unlinking (UNLINK=>1, which is default). Can you test to see if it works? If so we can get rid of @TEMP_FILES (which isn't used AFAICT); if not we can use @TEMP_FILES and unlink everything in an END block in Bio::Root::Test. cjfields
Download (untitled) / with headers
text/plain 689b
Show quoted text
> However, the above works if you close the filehandle but allow > unlinking (UNLINK=>1, which is default). Can you test to see > if it works? If so we can get rid of @TEMP_FILES (which isn't > used AFAICT); if not we can use @TEMP_FILES and unlink everything in > an END block in Bio::Root::Test.
You are absolutely right. The following patch is enough: ***** diff -r -u BioPerl-1.6.0/Bio/Root/Test.pm BioPerl-1.6.0patched/Bio/Root/Test.pm --- BioPerl-1.6.0/Bio/Root/Test.pm +++ BioPerl-1.6.0patched/Bio/Root/Test.pm @@ -301,6 +301,7 @@ my $tmp = File::Temp->new(); push(@TEMP_FILES, $tmp); + close($tmp); #Win32 needs this return $tmp->filename; } **** -- kmx
Download (untitled) / with headers
text/plain 846b
Patch committed to bioperl svn in r15990. thanks! -cjfields On Wed Aug 19 16:08:57 2009, KMX wrote: Show quoted text
> > However, the above works if you close the filehandle but allow > > unlinking (UNLINK=>1, which is default). Can you test to see > > if it works? If so we can get rid of @TEMP_FILES (which isn't > > used AFAICT); if not we can use @TEMP_FILES and unlink everything in > > an END block in Bio::Root::Test.
> > You are absolutely right. The following patch is enough: > > ***** > diff -r -u BioPerl-1.6.0/Bio/Root/Test.pm > BioPerl-1.6.0patched/Bio/Root/Test.pm > --- BioPerl-1.6.0/Bio/Root/Test.pm > +++ BioPerl-1.6.0patched/Bio/Root/Test.pm > @@ -301,6 +301,7 @@ > > my $tmp = File::Temp->new(); > push(@TEMP_FILES, $tmp); > + close($tmp); #Win32 needs this > > return $tmp->filename; > } > **** > > -- > kmx >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.