diff options
author | Dominic Hargreaves <dom@earth.li> | 2014-02-09 21:59:21 +0000 |
---|---|---|
committer | Dominic Hargreaves <dom@earth.li> | 2014-02-09 21:59:21 +0000 |
commit | e8d4d78c9499b332006ffc8ed9b5060a9b99135e (patch) | |
tree | 2540f766be62a817e9c16e15ef8d9a7bc7a7800a | |
parent | 82f377f75bcf68a52978aa36934577f18945e7cd (diff) |
Imported Upstream version 0.09
-rw-r--r-- | .gitignore | 22 | ||||
-rwxr-xr-x | Changes | 11 | ||||
-rwxr-xr-x | MANIFEST | 77 | ||||
-rwxr-xr-x | MANIFEST.skip | 2 | ||||
-rw-r--r-- | META.json | 43 | ||||
-rw-r--r--[-rwxr-xr-x] | META.yml | 37 | ||||
-rwxr-xr-x | README | 4 | ||||
-rwxr-xr-x | lib/Test/HTML/Content.pm | 11 | ||||
-rwxr-xr-x | lib/Test/HTML/Content/NoXPath.pm | 2 | ||||
-rwxr-xr-x | lib/Test/HTML/Content/XPathExtensions.pm | 2 | ||||
-rwxr-xr-x | t/01-libxml-xpath-abstraction.t | 27 | ||||
-rwxr-xr-x | t/07-errors.link.t | 16 | ||||
-rwxr-xr-x | t/08-errors.comment.t | 10 | ||||
-rw-r--r-- | t/99-changes.t | 28 | ||||
-rw-r--r-- | t/99-versions.t | 51 | ||||
-rw-r--r--[-rwxr-xr-x] | t/embedded-Test-HTML-Content-NoXPath.t | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | t/embedded-Test-HTML-Content-XPathExtensions.t | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | t/embedded-Test-HTML-Content.t | 0 |
18 files changed, 278 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a5d777 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +Thumbs.db +_Inline +ccv-src/ +out.png +blib/ +*.bak +Makefile +Makefile.old +pm_to_blib +CCV.def +CCV.inl +CCV.c +*.bs +*.old +*.o +dll.base +dll.exp +.releaserc +Test-HTML-Content-*.tar +Test-HTML-Content-*.tar.gz +Test-HTML-Content-*/ +MYMETA.*
\ No newline at end of file @@ -1,5 +1,16 @@ Revision history for Perl extension Test::HTML::Content. +0.09 20130206 + - Apply patch from RT 70099, by gregor herrmann and dom + This fixes bugs in the test suite + <http://bugs.debian.org/cgi-bin /bugreport.cgi?bug=636520> + and RT 70099 + - Apply patch from RT 42072 by gyles19@visi.com + This fixes the crash when using XML::XPath instead of XML::LibXML + +0.08 20081112 + ??? + 0.07 20031230 - Fixed test bug reported by Kate Pugh (KAKE): t/09-errors.xpath.t was missing a SKIP: label @@ -1,36 +1,41 @@ -Changes -lib/Test/HTML/Content.pm -lib/Test/HTML/Content/NoXPath.pm -lib/Test/HTML/Content/XPathExtensions.pm -Makefile.PL -MANIFEST This list of files -MANIFEST.skip -META.yml -README -t/00-prerequisites.t -t/01-fallback-libxml.t -t/01-fallback-pureperl.t -t/01-fallback-xpath.t -t/01-internal-api.t -t/01-xpath-query-builder.t -t/02-tags.t -t/03-links.t -t/04-comments.t -t/05-doctype.t -t/06-text.t -t/07-errors.link.t -t/08-errors.comment.t -t/09-errors.declaration.t -t/09-errors.xpath.t -t/10-errors.text.t -t/12-title-fallback.t -t/12-title.t -t/13-xpath-gracefull-errors.t -t/99-manifest.t -t/99-Pod.t -t/99-todo.t -t/99-unix-text.t -t/embedded-Test-HTML-Content-NoXPath.t -t/embedded-Test-HTML-Content-XPathExtensions.t -t/embedded-Test-HTML-Content.t -t/testlib.pm +.gitignore
+Changes
+lib/Test/HTML/Content.pm
+lib/Test/HTML/Content/NoXPath.pm
+lib/Test/HTML/Content/XPathExtensions.pm
+Makefile.PL
+MANIFEST This list of files
+MANIFEST.skip
+META.yml
+README
+t/00-prerequisites.t
+t/01-fallback-libxml.t
+t/01-fallback-pureperl.t
+t/01-fallback-xpath.t
+t/01-internal-api.t
+t/01-libxml-xpath-abstraction.t
+t/01-xpath-query-builder.t
+t/02-tags.t
+t/03-links.t
+t/04-comments.t
+t/05-doctype.t
+t/06-text.t
+t/07-errors.link.t
+t/08-errors.comment.t
+t/09-errors.declaration.t
+t/09-errors.xpath.t
+t/10-errors.text.t
+t/12-title-fallback.t
+t/12-title.t
+t/13-xpath-gracefull-errors.t
+t/99-changes.t
+t/99-manifest.t
+t/99-Pod.t
+t/99-todo.t
+t/99-unix-text.t
+t/99-versions.t
+t/embedded-Test-HTML-Content-NoXPath.t
+t/embedded-Test-HTML-Content-XPathExtensions.t
+t/embedded-Test-HTML-Content.t
+t/testlib.pm
+META.json Module JSON meta-data (added by MakeMaker) diff --git a/MANIFEST.skip b/MANIFEST.skip index 19e7dba..eb2e0ef 100755 --- a/MANIFEST.skip +++ b/MANIFEST.skip @@ -21,3 +21,5 @@ _uu$ ^Test-HTML-Content-.*/ .*\.db$ ^cvstest$ +^MYMETA.* +^.git/ diff --git a/META.json b/META.json new file mode 100644 index 0000000..41d8db8 --- /dev/null +++ b/META.json @@ -0,0 +1,43 @@ +{ + "abstract" : "unknown", + "author" : [ + "unknown" + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Test-HTML-Content", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : 0 + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : 0 + } + }, + "runtime" : { + "requires" : { + "HTML::TokeParser" : 0, + "Test::Builder" : 0, + "Test::More" : 0 + } + } + }, + "release_status" : "stable", + "version" : "0.09" +} @@ -1,15 +1,24 @@ ---- #YAML:1.0 -name: Test-HTML-Content -version: 0.08 -abstract: ~ -license: ~ -author: ~ -generated_by: ExtUtils::MakeMaker version 6.42 -distribution_type: module -requires: - HTML::TokeParser: 0 - Test::Builder: 0 - Test::More: 0 +--- +abstract: unknown +author: + - unknown +build_requires: + ExtUtils::MakeMaker: 0 +configure_requires: + ExtUtils::MakeMaker: 0 +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' +license: unknown meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.3.html - version: 1.3 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Test-HTML-Content +no_index: + directory: + - t + - inc +requires: + HTML::TokeParser: 0 + Test::Builder: 0 + Test::More: 0 +version: 0.09 @@ -1,4 +1,4 @@ -Test::HTML::Content version 0.04
+Test::HTML::Content version 0.09
=========================
This module provides an easy way to test elements of
@@ -23,4 +23,4 @@ COPYRIGHT AND LICENCE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
-Copyright (C) 2002 Max Maischein, corion@cpan.org
\ No newline at end of file +Copyright (C) 2002-2013 Max Maischein, corion@cpan.org
\ No newline at end of file diff --git a/lib/Test/HTML/Content.pm b/lib/Test/HTML/Content.pm index 3e4dfd7..a08c414 100755 --- a/lib/Test/HTML/Content.pm +++ b/lib/Test/HTML/Content.pm @@ -37,7 +37,7 @@ use vars qw( $tidy ); xpath_ok no_xpath xpath_count ); -$VERSION = '0.08'; +$VERSION = '0.09'; my $Test = Test::Builder->new; @@ -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) }; diff --git a/lib/Test/HTML/Content/NoXPath.pm b/lib/Test/HTML/Content/NoXPath.pm index 8d53c22..081a8c3 100755 --- a/lib/Test/HTML/Content/NoXPath.pm +++ b/lib/Test/HTML/Content/NoXPath.pm @@ -10,7 +10,7 @@ use HTML::TokeParser; eval 'use warnings;' if ($] >= 5.006); use vars qw( $HTML_PARSER_StripsTags $VERSION @exports ); -$VERSION = '0.08'; +$VERSION = '0.09'; BEGIN { # Check whether HTML::Parser is v3 and delivers the comments starting diff --git a/lib/Test/HTML/Content/XPathExtensions.pm b/lib/Test/HTML/Content/XPathExtensions.pm index b2d7c3e..b620453 100755 --- a/lib/Test/HTML/Content/XPathExtensions.pm +++ b/lib/Test/HTML/Content/XPathExtensions.pm @@ -10,7 +10,7 @@ use HTML::TokeParser; eval 'use warnings;' if ($] >= 5.006); use vars qw( $HTML_PARSER_StripsTags $VERSION @exports ); -$VERSION = '0.08'; +$VERSION = '0.09'; @exports = qw( matches comment ); diff --git a/t/01-libxml-xpath-abstraction.t b/t/01-libxml-xpath-abstraction.t new file mode 100755 index 0000000..bbce562 --- /dev/null +++ b/t/01-libxml-xpath-abstraction.t @@ -0,0 +1,27 @@ +#!/usr/bin/perl -w +use strict; +use Test::More; +use lib 't'; +use testlib; + +# This test file tests the abstraction +# of XML::LibXML and XML::XPath nodes + +my $HTML = '<html><body onload="foo()">test</body></html>'; + +sub run { + my ($implementation) = @_; + SKIP: { + skip "Tests irrelevant for pure Perl implementation", 4 + if $implementation eq 'PurePerl'; + use_ok('Test::HTML::Content'); + my $tree = Test::HTML::Content::__get_node_tree($HTML, '/html/body'); + isn't( $tree, undef, "Got body node"); + foreach my $node ($tree->get_nodelist) { + is( Test::HTML::Content::__get_node_content($node,'onload'), 'foo()', 'onload attribute'); + is( Test::HTML::Content::__get_node_content($node,'_content'), 'test','_content pseudo attribute'); + }; + }; +}; + +runtests( 4,\&run ); diff --git a/t/07-errors.link.t b/t/07-errors.link.t index 9fa7046..5c120cf 100755 --- a/t/07-errors.link.t +++ b/t/07-errors.link.t @@ -14,6 +14,10 @@ BEGIN { } }; +# perldelta 5.14 +# Accept both old and new-style stringification +my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? "^" : "-xism"; + sub run { # Test that each exported function fails as documented test_out("not ok 1 - Link failure (no links)"); @@ -51,13 +55,13 @@ sub run { test_fail(+14); if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') { test_diag("Expected to find no <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", ' <a href="http://www.foo.com">foo</a>', ' <a href="index.html">Home</a>'); } else { test_diag("Expected to find no <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", " <a href='http://www.foo.com'>", " <a href='index.html'>"); @@ -70,13 +74,13 @@ sub run { test_fail(+14); if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') { test_diag("Expected to find exactly 3 <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", ' <a href="http://www.foo.com">foo</a>', ' <a href="index.html">Home</a>'); } else { test_diag("Expected to find exactly 3 <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", " <a href='http://www.foo.com'>", " <a href='index.html'>"); @@ -88,7 +92,7 @@ sub run { test_fail(+18); if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') { test_diag("Expected to find exactly 3 <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", ' <a href="http://www.bar.com">bar</a>', ' <a href="http://www.dot.com">.</a>', @@ -96,7 +100,7 @@ sub run { ' <a href="index.html">Home</a>'); } else { test_diag("Expected to find exactly 3 <a> tag(s) matching", - " href = (?-xism:.)", + " href = (?$modifiers:.)", "Got", " <a href='http://www.bar.com'>", " <a href='http://www.dot.com'>", diff --git a/t/08-errors.comment.t b/t/08-errors.comment.t index af224cc..8c4765a 100755 --- a/t/08-errors.comment.t +++ b/t/08-errors.comment.t @@ -13,6 +13,10 @@ if ($@) { plan skip_all => "Test::Builder::Tester required for testing error messages"; } +# perldelta 5.14 +# Accept both old and new-style stringification +my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? "^" : "-xism"; + sub run { # Test that each exported function fails as documented @@ -48,7 +52,7 @@ sub run { #} else { test_diag("Saw '<!-- hidden massage -->'", "Saw '<!-- hidden massage -->'", - "Expected no comment like '(?-xism:hidden m.ssage)'"); + "Expected no comment like '(?$modifiers:hidden m.ssage)'"); #}; no_comment("<!-- hidden massage --><!-- hidden massage -->", qr"hidden m.ssage","Comment failure (two comments that shouldn't exist do)"); @@ -61,7 +65,7 @@ sub run { #} else { test_diag("Saw '<!-- hidden massage -->'", "Saw '<!-- hidden massage -->'", - "Expected exactly 3 comments like '(?-xism:hidden m.ssage)'"); + "Expected exactly 3 comments like '(?$modifiers:hidden m.ssage)'"); #}; comment_count("<!-- hidden massage --><!-- hidden massage -->", qr"hidden m.ssage",3,"Comment failure (too few comments)"); @@ -74,7 +78,7 @@ sub run { #} else { test_diag("Saw '<!-- hidden massage -->'", "Saw '<!-- hidden massage -->'", - "Expected exactly 1 comments like '(?-xism:hidden m.ssage)'"); + "Expected exactly 1 comments like '(?$modifiers:hidden m.ssage)'"); #}; comment_count("<!-- hidden massage --><!-- hidden massage -->", qr"hidden m.ssage",1,"Comment failure (too few comments)"); diff --git a/t/99-changes.t b/t/99-changes.t new file mode 100644 index 0000000..c4726f5 --- /dev/null +++ b/t/99-changes.t @@ -0,0 +1,28 @@ +#!perl -w
+use warnings;
+use strict;
+use File::Find;
+use Test::More tests => 2;
+
+=head1 PURPOSE
+
+This test ensures that the Changes file
+mentions the current version and that a
+release date is mentioned as well
+
+=cut
+
+my $module = 'Test::HTML::Content';
+
+(my $file = $module) =~ s!::!/!g;
+require "$file.pm";
+
+my $version = sprintf '%0.2f', $module->VERSION;
+diag "Checking for version " . $version;
+
+my $changes = do { local $/; open my $fh, 'Changes' or die $!; <$fh> };
+
+ok $changes =~ /^(.*$version.*)$/m, "We find version $version";
+my $changes_line = $1;
+ok $changes_line =~ /$version\s+20\d{6}/, "We find a release date on the same line"
+ or diag $changes_line;
diff --git a/t/99-versions.t b/t/99-versions.t new file mode 100644 index 0000000..49da187 --- /dev/null +++ b/t/99-versions.t @@ -0,0 +1,51 @@ +#!perl -w
+
+# Stolen from ChrisDolan on use.perl.org
+# http://use.perl.org/comments.pl?sid=29264&cid=44309
+
+use warnings;
+use strict;
+use File::Find;
+use Test::More;
+BEGIN {
+ eval 'use File::Slurp; 1';
+ if ($@) {
+ plan skip_all => "File::Slurp needed for testing";
+ exit 0;
+ };
+};
+
+plan 'no_plan';
+
+my $last_version = undef;
+
+sub check {
+ return if (! m{blib/script/}xms && ! m{\.pm \z}xms);
+
+ my $content = read_file($_);
+
+ # only look at perl scripts, not sh scripts
+ return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms);
+
+ my @version_lines = $content =~ m/ ( [^\n]* \$VERSION \s* = [^=] [^\n]* ) /gxms;
+ if (@version_lines == 0) {
+ fail($_);
+ }
+ for my $line (@version_lines) {
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ if (!defined $last_version) {
+ $last_version = shift @version_lines;
+ diag "Checking for $last_version";
+ pass($_);
+ } else {
+ is($line, $last_version, $_);
+ }
+ }
+}
+
+find({wanted => \&check, no_chdir => 1}, 'blib');
+
+if (! defined $last_version) {
+ fail('Failed to find any files with $VERSION');
+}
diff --git a/t/embedded-Test-HTML-Content-NoXPath.t b/t/embedded-Test-HTML-Content-NoXPath.t index b033ee9..b033ee9 100755..100644 --- a/t/embedded-Test-HTML-Content-NoXPath.t +++ b/t/embedded-Test-HTML-Content-NoXPath.t diff --git a/t/embedded-Test-HTML-Content-XPathExtensions.t b/t/embedded-Test-HTML-Content-XPathExtensions.t index 1920aaf..1920aaf 100755..100644 --- a/t/embedded-Test-HTML-Content-XPathExtensions.t +++ b/t/embedded-Test-HTML-Content-XPathExtensions.t diff --git a/t/embedded-Test-HTML-Content.t b/t/embedded-Test-HTML-Content.t index 2fa342d..2fa342d 100755..100644 --- a/t/embedded-Test-HTML-Content.t +++ b/t/embedded-Test-HTML-Content.t |