Skip Menu |
 

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

Report information
The Basics
Id: 42072
Status: resolved
Priority: 0/
Queue: Test-HTML-Content

People
Owner: Nobody in particular
Requestors: gyles19 [...] visi.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08
Fixed in: 0.08



Subject: 01-fallback-xpath.t failure
Download (untitled) / with headers
text/plain 1.4k
# prove -b -v t/01-fallback-xpath.t t/01-fallback-xpath.... 1..4 ok 1 - use Test::HTML::Content; ok 2 - Finding a link works without XML::LibXML not ok 3 - Missing prerequisites don't let the tests fail # Failed test 'Missing prerequisites don't let the tests fail' # at t/01-fallback-xpath.t line 20. # got: 'No such method textContent in XML::XPath::Node::ElementImpl at /root/.cpan/build/Test-HTML-Content-0.08- WAcuBY/blib/lib/Test/HTML/Content.pm line 278 # ' # expected: '' not ok 4 - Skipped or passed when XML::LibXML is missing # Failed test 'Skipped or passed when XML::LibXML is missing' # at t/01-fallback-xpath.t line 21. # Expected 'skip' or '1', but got '' # Looks like you failed 2 tests of 4. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/4 subtests Test Summary Report ------------------- t/01-fallback-xpath (Wstat: 512 Tests: 4 Failed: 2) Failed tests: 3-4 Non-zero exit status: 2 Files=1, Tests=4, 1 wallclock secs ( 0.09 usr 0.02 sys + 0.36 cusr 0.02 csys = 0.49 CPU) Result: FAIL falcon:root:Test-HTML-Content-0.08-WAcuBY:1070 # Perl 5.8.8 on linux. Test::HTML::Content failed to properly isolate a call to XML::libXML's textContent function, so the test failed when it loaded XML::Xpath instead. Once that was fixed, I discovered that the two routines were returning different content, so I hunted through the POD until I found something that worked for both. With the attached patch applied, all tests pass.
Subject: fallback.patch
Download fallback.patch
text/x-diff 832b
diff --git a/lib/Test/HTML/Content.pm b/lib/Test/HTML/Content.pm index 3e4dfd7..d7abde1 100755 --- a/lib/Test/HTML/Content.pm +++ b/lib/Test/HTML/Content.pm @@ -69,6 +69,12 @@ sub __node_content { if ($can_xpath eq 'XML::LibXML') { return $node->toString }; }; +sub __text_content { + my $node = shift; + if ($can_xpath eq 'XML::XPath') { return $node->string_value }; + if ($can_xpath eq 'XML::LibXML') { return $node->textContent }; +} + sub __match_comment { my ($text,$template) = @_; $text =~ s/^<!--(.*?)-->$/$1/sm unless $HTML_PARSER_StripsTags; @@ -276,7 +282,8 @@ sub __get_node_content { my ($node,$name) = @_; if ($name eq '_content') { - return $node->textContent() + return __text_content( $node ) +# return $node->textContent() } else { return $node->getAttribute($name) };
Thanks for sending the patch! I've applied it and released v0.09


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.