Skip Menu |

This queue is for tickets about the XML-RSS CPAN distribution.

Report information
The Basics
Id: 23752
Status: resolved
Priority: 0/
Queue: XML-RSS

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

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



Subject: needs binmode when comparing size of string with its output
t\1.0-generate.t and t\2.0-generate.t fail on Win32 due to the lack of 'binmode' while saving files. Attached patch would fix these. --------------- C:\perl\perl5.8.4\.cpan\build\XML-RSS-1.20>nmake test Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. C:\perl\perl5.8.4\bin\perl.exe "-MTest::Manifest" "- e" "run_t_manifest(0, 'blib\lib', 'blib\arch', )" Level is Test::Manifest::test_harness found [t\load.t t\pod.t t\version.t t\encoding.t t\0.9-generate.t t\0.9-parse.t t\0.91-parse.t t\1.0- generate.t t\1.0-parse.t t\1.0-parse-exotic.t t\2.0-generate.t t\2.0- permalink.t t\2.0-parse.t t\2.0-wo-title.t t\1.0-to-2.0.t t\auto_add_modules.t t\enclosures.t t\enclosures2.t t\encode-output.t t\items-are-0.t t\rss2-gt-encoding.t t\charset1.t] t\load................ok t\pod.................ok t\version.............ok t\encoding............ok t\0.9-generate........ok t\0.9-parse...........ok t\0.91-parse..........ok t\1.0-generate........ok 1/22 t\1.0-generate........NOK 13/22# Failed test './t/1.0-generated.xml has '1448' characters.' # in t\1.0-generate.t at line 100. # got: 1448 # expected: 1402 # Looks like you failed 1 test of 22. t\1.0-generate........dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 13 Failed 1/22 tests, 95.45% okay t\1.0-parse...........ok t\1.0-parse-exotic....ok t\2.0-generate........NOK 14/26 # Failed test 't/2.0-generated.xml has '1561' characters.' # in t\2.0-generate.t at line 103. # got: '1561' # expected: '1513' # Looks like you failed 1 test of 26. t\2.0-generate........dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 14 Failed 1/26 tests, 96.15% okay t\2.0-permalink.......ok t\2.0-parse...........ok t\2.0-wo-title........ok t\1.0-to-2.0..........ok t\auto_add_modules....ok t\enclosures..........ok t\enclosures2.........ok t\encode-output.......ok t\items-are-0.........ok t\rss2-gt-encoding....ok t\charset1............ok Failed Test Stat Wstat Total Fail List of Failed ------------------------------------------------------------------------ ------- t\1.0-generate.t 1 256 22 1 13 t\2.0-generate.t 1 256 26 1 14 Failed 2/22 test scripts. 2/222 subtests failed. Files=22, Tests=222, 58 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU) Failed 2/22 test programs. 2/222 subtests failed. # Looks like your test died before it could output anything. NMAKE : fatal error U1077: 'C:\perl\perl5.8.4\bin\perl.exe' : リターン コード '0xff' Stop.
Subject: patch
Download patch
application/octet-stream 336b

Message body not shown because it is not plain text.

Subject: Improved Patch
From: SHLOMIF [...] cpan.org
On Sun Dec 03 07:04:27 2006, ISHIGAKI wrote: Show quoted text
> t\1.0-generate.t and t\2.0-generate.t fail on Win32 due to the lack
of Show quoted text
> 'binmode' while saving files. Attached patch would fix these. >
Hi! I don't like this because RSS is text and should be outputted as such. Attached is a better patch that resolves it in a better way. Instead of comparing the size of the file (in bytes) to the length of the string (in characters), slurp the file and "eq" its contents to the string. Here is my commit message for potential reuse: <<<<<<<<<< Made the -generate.t tests more robust - instead of checking for the file size, compare the contents of the file to the as_string() return value. That way LF/CRLF conversions and other such incompatibilities in calculating file size vs. string length can be mitigated. Show quoted text
>>>>>>>>>>
Ask, please apply it. Regards, Shlomi Fish Show quoted text
> --------------- > C:\perl\perl5.8.4\.cpan\build\XML-RSS-1.20>nmake test > > Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 > Copyright (C) Microsoft Corp 1988-1998. All rights reserved. > > C:\perl\perl5.8.4\bin\perl.exe "-MTest::Manifest" "- > e" "run_t_manifest(0, 'blib\lib', 'blib\arch', )" > Level is > Test::Manifest::test_harness found [t\load.t t\pod.t t\version.t > t\encoding.t t\0.9-generate.t t\0.9-parse.t t\0.91-parse.t t\1.0- > generate.t t\1.0-parse.t t\1.0-parse-exotic.t t\2.0-generate.t
t\2.0- Show quoted text
> permalink.t t\2.0-parse.t t\2.0-wo-title.t t\1.0-to-2.0.t > t\auto_add_modules.t t\enclosures.t t\enclosures2.t
t\encode-output.t Show quoted text
> t\items-are-0.t t\rss2-gt-encoding.t t\charset1.t] > t\load................ok > t\pod.................ok > t\version.............ok > t\encoding............ok > t\0.9-generate........ok > t\0.9-parse...........ok > t\0.91-parse..........ok > t\1.0-generate........ok 1/22 > t\1.0-generate........NOK 13/22# Failed
test './t/1.0-generated.xml Show quoted text
> has '1448' characters.' > # in t\1.0-generate.t at line 100. > # got: 1448 > # expected: 1402 > # Looks like you failed 1 test of 22. > t\1.0-generate........dubious > Test returned status 1 (wstat 256, 0x100) > DIED. FAILED test 13 > Failed 1/22 tests, 95.45% okay > t\1.0-parse...........ok > t\1.0-parse-exotic....ok > t\2.0-generate........NOK 14/26 > # Failed test 't/2.0-generated.xml has '1561' characters.' > # in t\2.0-generate.t at line 103. > # got: '1561' > # expected: '1513' > # Looks like you failed 1 test of 26. > t\2.0-generate........dubious > Test returned status 1 (wstat 256, 0x100) > DIED. FAILED test 14 > Failed 1/26 tests, 96.15% okay > t\2.0-permalink.......ok > t\2.0-parse...........ok > t\2.0-wo-title........ok > t\1.0-to-2.0..........ok > t\auto_add_modules....ok > t\enclosures..........ok > t\enclosures2.........ok > t\encode-output.......ok > t\items-are-0.........ok > t\rss2-gt-encoding....ok > t\charset1............ok > Failed Test Stat Wstat Total Fail List of Failed > ------------------------------------------------------------------------ > ------- > t\1.0-generate.t 1 256 22 1 13 > t\2.0-generate.t 1 256 26 1 14 > Failed 2/22 test scripts. 2/222 subtests failed. > Files=22, Tests=222, 58 wallclock secs ( 0.00 cusr + 0.00 csys =
0.00 Show quoted text
> CPU) > Failed 2/22 test programs. 2/222 subtests failed. > # Looks like your test died before it could output anything. > NMAKE : fatal error U1077: 'C:\perl\perl5.8.4\bin\perl.exe' : リターン コー
ド Show quoted text
> '0xff' > Stop.
=== t/1.0-generate.t ================================================================== --- t/1.0-generate.t (revision 483) +++ t/1.0-generate.t (revision 484) @@ -90,15 +90,23 @@ RSS_MOD_PREFIX, "Namespace URI is ".RSS_MOD_URI); -my $len = length($rss->as_string()); +my $as_string = $rss->as_string(); +my $len = length($as_string); ok($len,"RSS feed has '$len' characters"); ok($rss->save(RSS_SAVEAS), "Wrote to disk: ".RSS_SAVEAS); -my $size = (stat(RSS_SAVEAS))[7]; -cmp_ok($size,"==",$len,RSS_SAVEAS." has '$size' characters."); +my $file_contents; +{ + local $/; + open I, "<", RSS_SAVEAS(); + $file_contents = <I>; + close(I); +} +cmp_ok($file_contents,"eq",$as_string,RSS_SAVEAS." contains the as_string() result"); + eval { $rss->parsefile(RSS_SAVEAS)}; is($@,'',"Parsed ".RSS_SAVEAS); === t/2.0-generate.t ================================================================== --- t/2.0-generate.t (revision 483) +++ t/2.0-generate.t (revision 484) @@ -94,14 +94,23 @@ is( $rss->{modules}->{$uri}, RSS_MOD_PREFIX, "Namespace URI is " . RSS_MOD_URI); -my $len = length($rss->as_string()); +my $as_string = $rss->as_string(); +my $len = length($as_string); ok( $len, "RSS feed has '$len' characters" ); ok( $rss->save(RSS_SAVEAS), "Wrote to disk: " . RSS_SAVEAS ); -my $size = -s (RSS_SAVEAS); -is( $size, $len, RSS_SAVEAS . " has '$size' characters."); +my $file_contents; +{ + local $/; + open I, "<", RSS_SAVEAS(); + $file_contents = <I>; + close(I); +} + +is($file_contents,$as_string,RSS_SAVEAS." contains the as_string() result"); + eval { $rss->parsefile( RSS_SAVEAS ) }; is( $@, '', "Parsed " . RSS_SAVEAS );
Applied, thanks (r8404). The change will be in v1.22.