Skip Menu |

This queue is for tickets about the Text-Diff CPAN distribution.

Report information
The Basics
Id: 7087
Status: open
Worked: 10 min
Priority: 0/
Queue: Text-Diff

People
Owner: Nobody in particular
Requestors: maxb [...] ukf.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.35
Fixed in: (no value)



Subject: Test failure on Cygwin - easy fix
The testsuite fails on Cygwin, hindering CPAN install. The problem is a small one: The same output temporary file is used twice consecutively. Windows can sometimes be lazy about releasing file locks, with the result that the second use fails. The fix is trivial - use a different temporary file name for the second test. Patch attached.
--- Text-Diff-0.35/t/outputs.t.orig 2004-07-24 11:37:00.127883200 +0100 +++ Text-Diff-0.35/t/outputs.t 2004-07-24 11:38:53.420790400 +0100 @@ -30,11 +30,11 @@ sub { require IO::File ; - my $fh = IO::File->new( ">output.t.foo" ) ; + my $fh = IO::File->new( ">output.t.foo2" ) ; _d $fh ; $fh = undef ; - ok slurp "output.t.foo", $expected ; - unlink "output.t.foo" or warn $! ; + ok slurp "output.t.foo2", $expected ; + unlink "output.t.foo2" or warn $! ; }, sub { ok 0 < index( diff( \"\n", \"", { STYLE => "Table" } ), "\\n" ) },
From: cpan [...] pjedwards.co.uk
On Sun Jul 25 13:23:18 2004, guest wrote: Show quoted text
> The testsuite fails on Cygwin, hindering CPAN install. > > The problem is a small one: The same output temporary file is used > twice consecutively. Windows can sometimes be lazy about releasing > file locks, with the result that the second use fails. The fix is > trivial - use a different temporary file name for the second test. > > Patch attached.
Just wanted to add that this test case, (and suggested patch for Cygwin) fail on VMS, a filename with two periods '.' is not a valid filename under VMS. From: http://perldoc.perl.org/perlport.html#Files-and-Filesystems "Do not have two files or directories of the same name with different case, like test.pl and Test.pl, as many platforms have case-insensitive (or at least case-forgiving) filenames. Also, try not to have non-word characters (except for .) in the names, and keep them to the 8.3 convention, for maximum portability, onerous a burden though this may appear." Thanks, Peter (Stig) Edwards
From: alexander.danel [...] gmail.com
With 'cygwin', in module Text::Diff, for the error: t/outputs.......No such file or directory at t/outputs.t line 37, <SLURP> line 6. I had to comment out line 29, where the 'unlink "output.t.foo"' command appears. (There are two 'unlink' commands in the file, only this, the first one, needs to be commented out.) The proposed patch of using two different names didn't work or me. AL_X # - - - - - - - - - - On Sun Jul 25 13:23:18 2004, guest wrote: Show quoted text
> The testsuite fails on Cygwin, hindering CPAN install. > > The problem is a small one: The same output temporary file is used > twice consecutively. Windows can sometimes be lazy about releasing > file locks, with the result that the second use fails. The fix is > trivial - use a different temporary file name for the second test. > > Patch attached.
On Wed Sep 19 10:13:44 2007, alexander.danel@gmail.com wrote: Show quoted text
> With 'cygwin', in module Text::Diff, for the error: > > t/outputs.......No such file or directory at t/outputs.t line 37, > <SLURP> line 6.
Works for me, cygwin perl-5.8.8 and perl-5.10.0. But I improved the patch a bit. Show quoted text
> I had to comment out line 29, where the 'unlink "output.t.foo"' > command appears. (There are two 'unlink' commands in the file, > only this, the first one, needs to be commented out.) > > The proposed patch of using two different names didn't work or me. > > AL_X > > # - - - - - - - - - - > On Sun Jul 25 13:23:18 2004, guest wrote:
> > The testsuite fails on Cygwin, hindering CPAN install. > > > > The problem is a small one: The same output temporary file is used > > twice consecutively. Windows can sometimes be lazy about releasing > > file locks, with the result that the second use fails. The fix is > > trivial - use a different temporary file name for the second test. > > > > Patch attached.
> >
-- Reini Urban
difforig Text-Diff-0.35 2007-10-07 Reini Urban <rurban@x-ray.at> diff -ub Text-Diff-0.35/lib/Text/Diff.pm.orig --- Text-Diff-0.35/lib/Text/Diff.pm.orig 2002-08-27 17:53:13.000000000 +0000 +++ Text-Diff-0.35/lib/Text/Diff.pm 2007-10-07 11:27:03.843750000 +0000 @@ -1,6 +1,6 @@ package Text::Diff; -$VERSION = 0.35; +$VERSION = "0.35_01"; =head1 NAME diff -ub Text-Diff-0.35/t/general.t.orig --- Text-Diff-0.35/t/general.t.orig 2001-12-16 12:42:15.000000000 +0000 +++ Text-Diff-0.35/t/general.t 2007-10-07 11:23:49.859375000 +0000 @@ -126,8 +126,8 @@ warn "# diff options: $diff_opts\n" ; warn "# my options: $Diff_opts\n" ; ## Merge the outputs using A::D - my @E = split /^/g, $expect ; - my @G = split /^/g, $output ; + my @E = split /^/, $expect ; + my @G = split /^/, $output ; my $w = length "Expected" ; for ( @E, @G ) { s/\n/\\n/g ; diff -ub Text-Diff-0.35/t/outputs.t.orig --- Text-Diff-0.35/t/outputs.t.orig 2002-08-27 17:52:50.000000000 +0000 +++ Text-Diff-0.35/t/outputs.t 2007-10-07 11:22:33.609375000 +0000 @@ -30,11 +30,11 @@ sub { require IO::File ; - my $fh = IO::File->new( ">output.t.foo" ) ; + my $fh = IO::File->new( ">output.t.foo2" ) ; _d $fh ; $fh = undef ; - ok slurp "output.t.foo", $expected ; - unlink "output.t.foo" or warn $! ; + ok slurp "output.t.foo2", $expected ; + unlink "output.t.foo2" or warn $! ; }, sub { ok 0 < index( diff( \"\n", \"", { STYLE => "Table" } ), "\\n" ) },
--- comment: "#7087: Test failure on Cygwin - easy fix" match: distribution: "^RBS/Text-Diff-0\.35\.tar\.gz$" patches: - "../Text-Diff-0.35.patch"
From: davembradford [...] gmail.com
closing the file in slurp() worked for me:
--- Text-Diff-0.35/t/outputs.t 2002-08-27 13:52:50.000000000 -0400 +++ Text-Diff-0.35.good/t/outputs.t 2008-06-06 17:47:43.563500000 -0400 @@ -9,7 +9,7 @@ sub _d($) { diff \@A, \@B, { OUTPUT => shift } } -sub slurp { open SLURP, "<" . shift or die $! ; return join "", <SLURP> } +sub slurp { open SLURP, "<" . shift or die $! ; my $jj = join "", <SLURP>; close SLURP; return $jj } my $expected = _d undef ;
On Fri Jun 06 18:08:00 2008, DBRADFORD wrote: Show quoted text
> closing the file in slurp() worked for me:
Reposting to display plain text --- Text-Diff-0.35/t/outputs.t 2002-08-27 13:52:50.000000000 -0400 +++ Text-Diff-0.35.good/t/outputs.t 2008-06-06 17:47:43.563500000 -0400 @@ -9,7 +9,7 @@ sub _d($) { diff \@A, \@B, { OUTPUT => shift } } -sub slurp { open SLURP, "<" . shift or die $! ; return join "", <SLURP> } +sub slurp { open SLURP, "<" . shift or die $! ; my $jj = join "", <SLURP>; close SLURP; return $jj } my $expected = _d undef ;
diff -u Text-Diff-0.35/t/general.t Text-Diff-0.35.good/t/general.t --- Text-Diff-0.35/t/general.t 2001-12-16 07:42:15.000000000 -0500 +++ Text-Diff-0.35.good/t/general.t 2008-06-06 17:48:34.204125000 -0400 @@ -126,8 +126,8 @@ warn "# diff options: $diff_opts\n" ; warn "# my options: $Diff_opts\n" ; ## Merge the outputs using A::D - my @E = split /^/g, $expect ; - my @G = split /^/g, $output ; + my @E = split /^/, $expect ; + my @G = split /^/, $output ; my $w = length "Expected" ; for ( @E, @G ) { s/\n/\\n/g ; diff -u Text-Diff-0.35/t/outputs.t Text-Diff-0.35.good/t/outputs.t --- Text-Diff-0.35/t/outputs.t 2002-08-27 13:52:50.000000000 -0400 +++ Text-Diff-0.35.good/t/outputs.t 2008-06-06 17:47:43.563500000 -0400 @@ -9,7 +9,7 @@ sub _d($) { diff \@A, \@B, { OUTPUT => shift } } -sub slurp { open SLURP, "<" . shift or die $! ; return join "", <SLURP> } +sub slurp { open SLURP, "<" . shift or die $! ; my $jj = join "", <SLURP>; close SLURP; return $jj } my $expected = _d undef ;
From: amir.aharoni [...] gmail.com
On Sun Jul 25 13:23:18 2004, guest wrote: Show quoted text
> The testsuite fails on Cygwin, hindering CPAN install. > > The problem is a small one: The same output temporary file is used > twice consecutively. Windows can sometimes be lazy about releasing > file locks, with the result that the second use fails. The fix is > trivial - use a different temporary file name for the second test. > > Patch attached.
Is it possible to incorporate this patch to the version on CPAN? It is impossible now to install this module using CPAN shell on Cygwin, and also impossible to install other modules that depend on this one - Test::Differences, Test::Most, Padre and probably others.
From: ddascalescu+perl [...] gmail.com
Quick update: I just got co-maintenance for this module and am working through thru bug queue. On Windows, the issue is that file HANDLES (like "SLURP") apparently aren't automatically closed as soon as they go out of scope. I didn't dig into why this happens because it's 2002-era code anyway. The modern way of doing a slurp is like this: sub slurp { open my $file_in, '<', shift or die $!; local $/; return <$file_in>; } Tests pass. Stay tuned, I'll try to release a new version tomorrow.