Subject: | bib.t fails on MSWin32 as tmpnam invalid |
t/bib.t fails as tmpnam returns a useless filename. I suggest attached
patch as an alternative.
with the fix, tests all pass.
thanks for the work on this module.
Subject: | text-bibtex.diff |
--- Text-BibTeX-0.55/t/bib.t Tue Apr 26 01:58:54 2011
+++ ../Text-BibTeX-0.55/t/bib.t Wed Jun 8 15:10:41 2011
@@ -4,7 +4,20 @@
use vars qw($DEBUG);
use IO::Handle;
-use POSIX qw(tmpnam);
+BEGIN {
+ # setup a safe temp name for win32
+ if ($^O =~ /Win32/) {
+ no strict 'refs';
+ my $i = 0;
+ *tmpnam = sub {
+ return $$.$i++;
+ };
+ }
+ else {
+ # for other platforms use Posix tmpnam
+ eval "use Posix qw(tmpnam);";
+ }
+}
use Test::More tests => 42;
@@ -40,7 +53,7 @@
# Entry objects blessed into a structured entry class, so start
# by creating the file to parse.
my $fn = tmpnam . ".bib";
-open F, '>', $fn || die "couldn't create $fn: $!\n";
+open F, '>', $fn or die "couldn't create $fn: $!\n";
print F $entries;
close F;