There are at least 3 issues, from what I can see:
- in t/utils.t:
* missing $lint->eof()
* <html>, <head>, <title> and <body>, aka "doc-level errors" or "doc-tag-required", need to be ignored too
Both of these issues could fixed by using Test::HTML::Lint's html_fragment_ok() instead of the hand-crafted t/utils.t - or maybe not because of the text-use-entity issues (which could possible be removed, as it's only used in t/utf8.t -->)
The third issue is that t/utf8.t fails, apparently HTML::Lint doesn't like unicode:
https://github.com/petdance/html-lint/issues/11
Attached is a patch with rather minimal changes in t/utils.t and commenting out the lint stuff from t/utf8.8
--- a/t/utf8.t
+++ b/t/utf8.t
@@ -24,14 +24,14 @@
1;
-use Test::More tests => 12;
+use Test::More tests => 6;
require "t/utils.pl";
{
my $simple = (show('simple_outs'));
ok($simple =~ m{^\s*$str\s*$}s);
# diag ($simple);
- ok_lint($simple);
+ #ok_lint($simple);
}
Template::Declare->buffer->clear;
@@ -39,21 +39,21 @@
my $simple = (show('double_outs'));
ok($simple =~ m{^\s*$str\s*$str\s*$}s);
# diag ($simple);
- ok_lint($simple);
+ #ok_lint($simple);
}
Template::Declare->buffer->clear;
{
my $simple = (show('tag_outs'));
ok($simple =~ m{^\s*<p>\s*$str\s*</p>\s*$}s);
- ok_lint($simple, 1);
+ #ok_lint($simple, 1);
}
Template::Declare->buffer->clear;
{
my $simple = (show('double_tag_outs'));
ok($simple =~ m{^\s*<p>\s*$str\s*</p>\s*<p>\s*$str\s*</p>\s*$}s);
- ok_lint($simple, 1);
+ #ok_lint($simple, 1);
}
Template::Declare->buffer->clear;
@@ -61,7 +61,7 @@
my $simple = (show('attr'));
ok($simple =~ m{^\s*<p\s+title="$str"\s*></p>\s*$}s);
# diag ($simple);
- ok_lint($simple);
+ #ok_lint($simple);
}
Template::Declare->buffer->clear;
@@ -69,7 +69,7 @@
my $simple = (show('attr_with_escape'));
ok($simple =~ m{^\s*<p\s+title="<$str>"\s*></p>\s*$}s);
#diag ($simple);
- ok_lint($simple);
+ #ok_lint($simple);
}
Template::Declare->buffer->clear;
--- a/t/utils.pl
+++ b/t/utils.pl
@@ -15,11 +15,13 @@
do {
local $SIG{__WARN__} = sub {}; # STFU HTML::Lint!
$lint->parse($html);
+ $lint->eof();
};
- # Collect the errors, ignore the invalid character errors when requested.
- my @errors = $ignore_chars
- ? grep { $_->errcode ne 'text-use-entity' } $lint->errors
- : $lint->errors;
+ # Collect the errors, ignore the doc-level errors, and invalid character errors when requested.
+ my @errors = grep { $_->errcode ne 'doc-tag-required' } $lint->errors;
+ @errors = $ignore_chars
+ ? grep { $_->errcode ne 'text-use-entity' } @errors
+ : @errors;
is( @errors, 0, "Lint checked clean" );
foreach my $error ( @errors ) {
diag( $error->as_string );