Hello community, here is the log from the commit of package perl-Test-WWW-Mechanize for openSUSE:Factory checked in at 2018-04-25 10:01:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Test-WWW-Mechanize (Old) and /work/SRC/openSUSE:Factory/.perl-Test-WWW-Mechanize.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Test-WWW-Mechanize" Wed Apr 25 10:01:07 2018 rev:9 rq:599329 version:1.50 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Test-WWW-Mechanize/perl-Test-WWW-Mechanize.changes 2017-01-10 10:46:41.296244478 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Test-WWW-Mechanize.new/perl-Test-WWW-Mechanize.changes 2018-04-25 10:01:11.611190724 +0200 @@ -1,0 +2,6 @@ +Tue Apr 17 06:00:00 UTC 2018 - co...@suse.com + +- updated to 1.50 + see /usr/share/doc/packages/perl-Test-WWW-Mechanize/Changes + +------------------------------------------------------------------- Old: ---- Test-WWW-Mechanize-1.48.tar.gz New: ---- Test-WWW-Mechanize-1.50.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Test-WWW-Mechanize.spec ++++++ --- /var/tmp/diff_new_pack.8HF5om/_old 2018-04-25 10:01:12.847145378 +0200 +++ /var/tmp/diff_new_pack.8HF5om/_new 2018-04-25 10:01:12.851145231 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Test-WWW-Mechanize # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,22 +17,22 @@ Name: perl-Test-WWW-Mechanize -Version: 1.48 +Version: 1.50 Release: 0 %define cpan_name Test-WWW-Mechanize Summary: Testing-specific WWW::Mechanize subclass License: Artistic-2.0 Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/Test-WWW-Mechanize/ -Source0: http://www.cpan.org/authors/id/P/PE/PETDANCE/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/P/PE/PETDANCE/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Carp::Assert::More) +BuildRequires: perl(HTML::Form) BuildRequires: perl(HTML::TokeParser) -BuildRequires: perl(HTML::TreeBuilder) BuildRequires: perl(HTTP::Server::Simple) >= 0.42 BuildRequires: perl(HTTP::Server::Simple::CGI) BuildRequires: perl(LWP) >= 6.02 @@ -43,8 +43,8 @@ BuildRequires: perl(WWW::Mechanize) >= 1.68 BuildRequires: perl(parent) Requires: perl(Carp::Assert::More) +Requires: perl(HTML::Form) Requires: perl(HTML::TokeParser) -Requires: perl(HTML::TreeBuilder) Requires: perl(HTTP::Server::Simple) >= 0.42 Requires: perl(HTTP::Server::Simple::CGI) Requires: perl(LWP) >= 6.02 ++++++ Test-WWW-Mechanize-1.48.tar.gz -> Test-WWW-Mechanize-1.50.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/Changes new/Test-WWW-Mechanize-1.50/Changes --- old/Test-WWW-Mechanize-1.48/Changes 2016-12-30 05:45:53.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/Changes 2018-04-16 22:18:22.000000000 +0200 @@ -5,7 +5,25 @@ https://github.com/petdance/test-www-mechanize/issues -1.48 Thu Dec 29 22:45:29 CST 2016 +1.50 Mon Apr 16 15:16:59 CDT 2018 +------------------------------------ +[FIXES] +Added html_tidy_ok() methods, analogous to html_lint_ok(). + +Remove unnecessary dependency on HTML::TreeBuilder. Thanks, Kent Fredric. + + +1.49_01 Mon Mar 26 10:58:51 CDT 2018 +------------------------------------ +[ENHANCEMENTS] +Adding autotidy functionality. autotidy lets you validate every page that +Mech gets using the HTML::Tidy5 module, just like the autolint feature +does with the HTML::Lint module. HTML::Tidy5 is a much more complete +HTML checking tool, and validates HTML5 which HTML::Lint does not. You +must have HTML::Tidy5 1.00 installed to use autotidy. + + +1.48 Thu Dec 29 22:45:29 CST 2016 ------------------------------------ [FIXES] The linting method html_lint_ok() was not calling the HTML::Lint API diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/MANIFEST new/Test-WWW-Mechanize-1.50/MANIFEST --- old/Test-WWW-Mechanize-1.48/MANIFEST 2016-12-30 05:49:39.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/MANIFEST 2018-04-16 22:19:39.000000000 +0200 @@ -6,6 +6,7 @@ t/00-load.t t/autolint.t +t/autotidy.t t/bad.html t/badlinks.html t/click_ok.t @@ -25,6 +26,7 @@ t/headers.t t/html/form.html t/html_lint_ok.t +t/html_tidy_ok.t t/html/scratch.html t/lacks_uncapped_inputs-bad.html t/lacks_uncapped_inputs-good.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/META.json new/Test-WWW-Mechanize-1.50/META.json --- old/Test-WWW-Mechanize-1.48/META.json 2016-12-30 05:49:39.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/META.json 2018-04-16 22:19:39.000000000 +0200 @@ -4,7 +4,7 @@ "Andy Lester <a...@petdance.com>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005", + "generated_by" : "ExtUtils::MakeMaker version 7.16, CPAN::Meta::Converter version 2.150005", "license" : [ "artistic_2" ], @@ -32,9 +32,10 @@ }, "runtime" : { "requires" : { + "Carp" : "0", "Carp::Assert::More" : "0", + "HTML::Form" : "0", "HTML::TokeParser" : "0", - "HTML::TreeBuilder" : "0", "HTTP::Server::Simple" : "0.42", "HTTP::Server::Simple::CGI" : "0", "LWP" : "6.02", @@ -61,6 +62,6 @@ "url" : "https://github.com/petdance/test-www-mechanize" } }, - "version" : "1.48", - "x_serialization_backend" : "JSON::PP version 2.27300" + "version" : "1.50", + "x_serialization_backend" : "JSON::PP version 2.27400" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/META.yml new/Test-WWW-Mechanize-1.50/META.yml --- old/Test-WWW-Mechanize-1.48/META.yml 2016-12-30 05:49:39.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/META.yml 2018-04-16 22:19:39.000000000 +0200 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005' +generated_by: 'ExtUtils::MakeMaker version 7.16, CPAN::Meta::Converter version 2.150005' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -18,9 +18,10 @@ - t - inc requires: + Carp: '0' Carp::Assert::More: '0' + HTML::Form: '0' HTML::TokeParser: '0' - HTML::TreeBuilder: '0' HTTP::Server::Simple: '0.42' HTTP::Server::Simple::CGI: '0' LWP: '6.02' @@ -36,5 +37,5 @@ homepage: https://github.com/petdance/test-www-mechanize license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/petdance/test-www-mechanize -version: '1.48' -x_serialization_backend: 'CPAN::Meta::YAML version 0.018' +version: '1.50' +x_serialization_backend: 'CPAN::Meta::YAML version 0.012' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/Makefile.PL new/Test-WWW-Mechanize-1.50/Makefile.PL --- old/Test-WWW-Mechanize-1.48/Makefile.PL 2016-08-02 21:49:26.000000000 +0200 +++ new/Test-WWW-Mechanize-1.50/Makefile.PL 2018-04-16 22:18:22.000000000 +0200 @@ -10,8 +10,9 @@ PL_FILES => {}, PREREQ_PM => { 'parent' => 0, + 'Carp' => 0, 'Carp::Assert::More' => 0, - 'HTML::TreeBuilder' => 0, + 'HTML::Form' => 0, 'HTTP::Server::Simple' => '0.42', 'HTTP::Server::Simple::CGI' => 0, 'HTML::TokeParser' => 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/Mechanize.pm new/Test-WWW-Mechanize-1.50/Mechanize.pm --- old/Test-WWW-Mechanize-1.48/Mechanize.pm 2016-12-30 05:45:56.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/Mechanize.pm 2018-04-16 22:18:22.000000000 +0200 @@ -9,11 +9,11 @@ =head1 VERSION -Version 1.48 +Version 1.50 =cut -our $VERSION = '1.48'; +our $VERSION = '1.50'; =head1 SYNOPSIS @@ -90,6 +90,8 @@ my $lint = HTML::Lint->new( only_types => HTML::Lint::Error::STRUCTURE ); my $mech = Test::WWW::Mechanize->new( autolint => $lint ); +The same is also possible with C<< autotidy => 1 >> to use HTML::Tidy5. + =over =item * get_ok() @@ -118,7 +120,8 @@ The C<< $mech->get_ok() >> only counts as one test in the test count. Both the main IO operation and the linting must pass for the entire test to pass. -You can control autolint on the fly with the C<< autolint >> method. +You can control autolint and autotidy on the fly with the C<autolint> +and C<autotidy> methods. =cut @@ -131,10 +134,12 @@ ); my $autolint = delete $args{autolint}; + my $autotidy = delete $args{autotidy}; my $self = $class->SUPER::new( %args ); $self->autolint( $autolint ); + $self->autotidy( $autotidy ); return $self; } @@ -160,12 +165,12 @@ $self->get( $url, %opts ); my $ok = $self->success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } -sub _maybe_lint { +sub _post_load_validation { my $self = shift; my $ok = shift; my $desc = shift; @@ -173,10 +178,33 @@ local $Test::Builder::Level = $Test::Builder::Level + 1; if ( $ok ) { - if ( $self->is_html && $self->autolint ) { - $ok = $self->_lint_content_ok( $desc ); + my $emitted_ok = 0; + if ( $self->is_html ) { + if ( $self->autolint && $self->autotidy ) { + my $msg = 'autolint & autotidy'; + $msg .= ": $desc" if defined $desc; + $TB->subtest( + $desc, + sub { + $self->_lint_content_ok(); + $self->_tidy_content_ok(); + } + ); + ++$emitted_ok; + } + else { + if ( $self->autolint ) { + $ok = $self->_lint_content_ok( $desc ); + ++$emitted_ok; + } + elsif ( $self->autotidy ) { + $ok = $self->_tidy_content_ok( $desc ); + ++$emitted_ok; + } + } } - else { + + if ( !$emitted_ok ) { $TB->ok( $ok, $desc ); } } @@ -225,6 +253,12 @@ well-behaved C<*_ok()> functions, it returns true if the test passed, or false if not. +B<NOTE> Due to compatibility reasons it is not possible to pass +additional LWP_options beyond form data via this method (such as +Content or Content-Type). It is recommend that you use WWW::Mechanize's +post() directly for instances where more granular control of the post +is needed. + A default description of "POST to $url" is used if none if provided. =cut @@ -236,7 +270,7 @@ $self->post( $url, \%opts ); my $ok = $self->success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } @@ -294,7 +328,7 @@ } my $ok = $self->success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } @@ -355,7 +389,7 @@ my $response = $self->submit_form( %{$parms} ); my $ok = $response && $response->is_success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } @@ -400,7 +434,7 @@ my $response = $self->follow_link( %{$parms} ); my $ok = $response && $response->is_success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } @@ -426,7 +460,7 @@ my $ok = $response->is_success; - $ok = $self->_maybe_lint( $ok, $desc ); + $ok = $self->_post_load_validation( $ok, $desc ); return $ok; } @@ -551,8 +585,9 @@ =head2 $mech->html_lint_ok( [$desc] ) -Checks the validity of the HTML on the current page. If the page is not -HTML, then it fails. The URI is automatically appended to the I<$desc>. +Checks the validity of the HTML on the current page using the HTML::Lint +module. If the page is not HTML, then it fails. The URI is automatically +appended to the I<$desc>. Note that HTML::Lint must be installed for this to work. Otherwise, it will blow up. @@ -579,12 +614,13 @@ return $ok; } + sub _lint_content_ok { + local $Test::Builder::Level = $Test::Builder::Level + 1; + my $self = shift; my $desc = shift; - local $Test::Builder::Level = $Test::Builder::Level + 1; - my $module = "HTML::Lint 2.20"; if ( not ( eval "use $module; 1;" ) ) { die "Test::WWW::Mechanize can't do linting without $module: $@"; @@ -619,6 +655,79 @@ return $ok; } + +=head2 $mech->html_tidy_ok( [$desc] ) + +Checks the validity of the HTML on the current page using the HTML::Tidy +module. If the page is not HTML, then it fails. The URI is automatically +appended to the I<$desc>. + +Note that HTML::tidy must be installed for this to work. Otherwise, +it will blow up. + +=cut + +sub html_tidy_ok { + my $self = shift; + my $desc = shift; + + my $uri = $self->uri; + $desc = $desc ? "$desc ($uri)" : $uri; + + my $ok; + + if ( $self->is_html ) { + $ok = $self->_tidy_content_ok( $desc ); + } + else { + $ok = $TB->ok( 0, $desc ); + $TB->diag( q{This page doesn't appear to be HTML, or didn't get the proper text/html content type returned.} ); + } + + return $ok; +} + + +sub _tidy_content_ok { + local $Test::Builder::Level = $Test::Builder::Level + 1; + + my $self = shift; + my $desc = shift; + + my $module = 'HTML::Tidy5 1.00'; + + if ( not ( eval "use $module; 1;" ) ) { + die "Test::WWW::Mechanize can't do tidying without $module: $@"; + } + + my $tidy = $self->{autotidy}; + if ( ref $tidy && $tidy->isa('HTML::Tidy5') ) { + $tidy->clear_messages(); + } + else { + $tidy = HTML::Tidy5->new(); + } + + $tidy->parse( '', $self->content ); + + my @messages = $tidy->messages; + my $nmessages = @messages; + my $ok; + if ( $nmessages ) { + $ok = $TB->ok( 0, $desc ); + $TB->diag( 'HTML::Tidy5 messages for ' . $self->uri ); + $TB->diag( $_->as_string ) for @messages; + my $s = $nmessages == 1 ? '' : 's'; + $TB->diag( "$nmessages message$s on the page" ); + } + else { + $ok = $TB->ok( 1, $desc ); + } + + return $ok; +} + + =head2 $mech->title_is( $str [, $desc ] ) Tells if the title of the page is the given string. @@ -641,7 +750,7 @@ Tells if the title of the page matches the given regex. - $mech->title_like( qr/Invoices for (.+)/ + $mech->title_like( qr/Invoices for (.+)/ ); =cut @@ -659,7 +768,7 @@ Tells if the title of the page matches the given regex. - $mech->title_unlike( qr/Invoices for (.+)/ + $mech->title_unlike( qr/Invoices for (.+)/ ); =cut @@ -1506,6 +1615,38 @@ } +=head2 $mech->autotidy( [$status] ) + +Without an argument, this method returns a true or false value indicating +whether autotidy is active. + +When passed an argument, autotidy is turned on or off depending on whether +the argument is true or false, and the previous autotidy status is returned. +As with the autotidy option of C<< new >>, C<< $status >> can be an +L<< HTML::Tidy5 >> object. + +If autotidy is currently using an L<< HTML::Tidy5 >> object you provided, +the return is that object, so you can change and exactly restore +autotidy status: + + my $old_status = $mech->autotidy( 0 ); + ... operations that should not be tidied ... + $mech->autotidy( $old_status ); + +=cut + +sub autotidy { + my $self = shift; + + my $ret = $self->{autotidy}; + if ( @_ ) { + $self->{autotidy} = shift; + } + + return $ret; +} + + =head2 $mech->grep_inputs( \%properties ) grep_inputs() returns an array of all the input controls in the @@ -1859,7 +2000,7 @@ =head1 COPYRIGHT & LICENSE -Copyright 2004-2016 Andy Lester. +Copyright 2004-2018 Andy Lester. This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/README.md new/Test-WWW-Mechanize-1.50/README.md --- old/Test-WWW-Mechanize-1.48/README.md 2016-12-30 05:44:52.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/README.md 2018-03-26 18:22:58.000000000 +0200 @@ -37,6 +37,27 @@ but has nicer diagnostics if they fail. +Test::WWW::Mechanize also has functionality to automatically validate every page it goes to. + + use Test::WWW::Mechanize; + + my $mech = Test::WWW::Mechanize->new( autotidy => 1 ); + $mech->get_ok( $url ); + +which can give errors like this: + + not ok 1 - GET $url + # Failed test '$url' + # at foo.pl line 7. + # HTML::Tidy5 messages for $url + # (11:1) Warning: missing </b> before </body> + # (7:18) Warning: <a> escaping malformed URI reference + # (7:18) Warning: <a> illegal characters found in URI + # (11:1) Warning: trimming empty <b> + +The autotidy feature requires the HTML::Tidy5 module. The similar, +but less robust, autolint feature requires the HTML::Lint module. + # INSTALLATION To install this module, run the following commands: @@ -48,7 +69,7 @@ # COPYRIGHT AND LICENSE -Copyright (C) 2004-2016 Andy Lester +Copyright (C) 2004-2018 Andy Lester This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/t/00-load.t new/Test-WWW-Mechanize-1.50/t/00-load.t --- old/Test-WWW-Mechanize-1.48/t/00-load.t 2016-07-09 04:56:03.000000000 +0200 +++ new/Test-WWW-Mechanize-1.50/t/00-load.t 2018-04-16 22:18:22.000000000 +0200 @@ -13,4 +13,16 @@ diag( "Testing Test::WWW::Mechanize $Test::WWW::Mechanize::VERSION, with WWW::Mechanize $WWW::Mechanize::VERSION, LWP $LWP::VERSION, Test::More $Test::More::VERSION, Perl $], $^X" ); +for my $module ( qw( HTML::Lint HTML::Tidy5 ) ) { + my $rc = eval "use $module; 1;"; + if ( $rc ) { + no strict 'refs'; + my $version = ${"${module}::VERSION"}; + diag( "Found $module $version" ); + } + else { + diag( "No $module found." ); + } +} + done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/t/autotidy.t new/Test-WWW-Mechanize-1.50/t/autotidy.t --- old/Test-WWW-Mechanize-1.48/t/autotidy.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/t/autotidy.t 2018-03-26 18:22:58.000000000 +0200 @@ -0,0 +1,154 @@ +#!/usr/bin/env perl -T + +use strict; +use warnings; +use Test::Builder::Tester; +use Test::More; +use URI::file; + +use Test::WWW::Mechanize; + +BEGIN { + my $module = 'HTML::Tidy5 1.00'; + + # Load HTML::Lint here for the imports + if ( not eval "use $module; 1;" ) { + plan skip_all => "$module is not installed, cannot test autotidy."; + } + plan tests => 5; +} + + +subtest 'Accessor and mutator' => sub { + plan tests => 17; + + my $tidy = HTML::Tidy5->new; + isa_ok( $tidy, 'HTML::Tidy5' ); + + ACCESSOR: { + my $mech = Test::WWW::Mechanize->new(); + ok( !$mech->autotidy(), 'no autotidy to new yields autotidy off' ); + + $mech = Test::WWW::Mechanize->new( autotidy => undef ); + ok( !$mech->autotidy(), 'undef to new yields autotidy off' ); + + $mech = Test::WWW::Mechanize->new( autotidy => 0 ); + ok( !$mech->autotidy(), '0 to new yields autotidy off' ); + + $mech = Test::WWW::Mechanize->new( autotidy => 1 ); + ok( $mech->autotidy(), '1 to new yields autotidy on' ); + + $mech = Test::WWW::Mechanize->new( autotidy => [] ); + ok( $mech->autotidy(), 'non-false, non-object to new yields autotidy on' ); + + $mech = Test::WWW::Mechanize->new( autotidy => $tidy ); + ok( $mech->autotidy(), 'HTML::Tidy5 object to new yields autotidy on' ); + } + + MUTATOR: { + my $mech = Test::WWW::Mechanize->new(); + + ok( !$mech->autotidy(0), '0 returns autotidy off' ); + ok( !$mech->autotidy(), '0 autotidy really off' ); + + ok( !$mech->autotidy(''), '"" returns autotidy off' ); + ok( !$mech->autotidy(), '"" autotidy really off' ); + + ok( !$mech->autotidy(1), '1 returns autotidy off (prior state)' ); + ok( $mech->autotidy(), '1 autotidy really on' ); + + ok( $mech->autotidy($tidy), 'HTML::Tidy5 object returns autotidy on (prior state)' ); + ok( $mech->autotidy(), 'HTML::Tidy5 object autotidy really on' ); + my $ret = $mech->autotidy( 0 ); + isa_ok( $ret, 'HTML::Tidy5' ); + ok( !$mech->autotidy(), 'autotidy off after nuking HTML::Tidy5 object' ); + } +}; + + +subtest 'Fluffy page has errors' => sub { + plan tests => 2; + + my $mech = Test::WWW::Mechanize->new( autotidy => 1 ); + isa_ok( $mech, 'Test::WWW::Mechanize' ); + + my $uri = URI::file->new_abs( 't/fluffy.html' )->as_string; + + test_out( "not ok 1 - GET $uri" ); + test_fail( +5 ); + test_err( "# HTML::Tidy5 messages for $uri" ); + test_err( '# (1:1) Warning: missing <!DOCTYPE> declaration' ); + test_err( '# (10:9) Warning: <img> lacks "alt" attribute' ); + test_err( '# 2 messages on the page' ); + $mech->get_ok( $uri ); + test_test( 'Fluffy page should have fluffy errors' ); +}; + + +subtest 'Custom tidy ignores fluffy errors' => sub { + plan tests => 4; + + my $tidy = HTML::Tidy5->new( { show_warnings => 0 } ); + isa_ok( $tidy, 'HTML::Tidy5' ); + + my $mech = Test::WWW::Mechanize->new( autotidy => $tidy ); + isa_ok( $mech, 'Test::WWW::Mechanize' ); + + my $uri = URI::file->new_abs( 't/fluffy.html' )->as_string; + $mech->get_ok( $uri, 'Fluffy page should not have errors' ); + + # And if we go to another page, the autolint object has been reset. + $mech->get_ok( $uri, 'Second pass at the fluffy page should not have errors, either' ); +}; + + +subtest 'Get good HTML' => sub { + plan tests => 3; + + my $mech = Test::WWW::Mechanize->new( autotidy => 1 ); + isa_ok( $mech, 'Test::WWW::Mechanize' ); + + my $uri = URI::file->new_abs( 't/good.html' )->as_string; + $mech->get_ok( $uri ); + + test_out( "ok 1 - GET $uri" ); + $mech->get_ok( $uri, "GET $uri" ); + test_test( 'Good GET, good HTML' ); +}; + + +subtest 'Get bad HTML' => sub { + plan tests => 3; + + my $mech = Test::WWW::Mechanize->new( autotidy => 1 ); + isa_ok( $mech, 'Test::WWW::Mechanize' ); + + my $uri = URI::file->new_abs( 't/bad.html' )->as_string; + + # Test via get_ok + test_out( "not ok 1 - GET $uri" ); + test_fail( +7 ); + test_err( "# HTML::Tidy5 messages for $uri" ); + test_err( '# (1:1) Warning: missing <!DOCTYPE> declaration' ); + test_err( '# (8:33) Warning: discarding unexpected </b>' ); + test_err( '# (8:9) Warning: missing </a>' ); + #test_err( '# (7:9) Warning: <a> proprietary attribute "hrex"' ); + test_err( '# 3 messages on the page' ); + $mech->get_ok( $uri, "GET $uri" ); + test_test( 'get_ok complains about bad HTML' ); + + # Test via follow_link_ok + test_out( 'not ok 1 - Following link back to bad.html' ); + test_fail( +7 ); + test_err( "# HTML::Tidy5 messages for $uri" ); + test_err( '# (1:1) Warning: missing <!DOCTYPE> declaration' ); + test_err( '# (8:33) Warning: discarding unexpected </b>' ); + test_err( '# (8:9) Warning: missing </a>' ); + #test_err( '# (7:9) Warning: <a> proprietary attribute "hrex"' ); + test_err( '# 3 messages on the page' ); + $mech->follow_link_ok( { text => 'Back to bad' }, 'Following link back to bad.html' ); + test_test( 'follow_link_ok complains about bad HTML' ); +}; + +done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/t/good.html new/Test-WWW-Mechanize-1.50/t/good.html --- old/Test-WWW-Mechanize-1.48/t/good.html 2016-07-09 04:56:03.000000000 +0200 +++ new/Test-WWW-Mechanize-1.50/t/good.html 2018-03-26 18:22:58.000000000 +0200 @@ -1,3 +1,4 @@ +<!DOCTYPE html> <html> <head> <title>Test Page</title> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/t/html_lint_ok.t new/Test-WWW-Mechanize-1.50/t/html_lint_ok.t --- old/Test-WWW-Mechanize-1.48/t/html_lint_ok.t 2016-07-09 04:56:03.000000000 +0200 +++ new/Test-WWW-Mechanize-1.50/t/html_lint_ok.t 2018-04-16 22:18:22.000000000 +0200 @@ -10,8 +10,9 @@ BEGIN { # Load HTML::Lint here for the imports - if ( not eval 'use HTML::Lint 2.20; 1;' ) { - plan skip_all => 'HTML::Lint is not installed, cannot test autolint' if $@; + my $module = 'HTML::Lint 2.20'; + if ( not eval "use $module; 1;" ) { + plan skip_all => "$module is not installed, cannot test html_lint_ok" if $@; } plan tests => 3; } @@ -35,3 +36,4 @@ } done_testing(); +exit 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Test-WWW-Mechanize-1.48/t/html_tidy_ok.t new/Test-WWW-Mechanize-1.50/t/html_tidy_ok.t --- old/Test-WWW-Mechanize-1.48/t/html_tidy_ok.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Test-WWW-Mechanize-1.50/t/html_tidy_ok.t 2018-04-16 22:18:22.000000000 +0200 @@ -0,0 +1,38 @@ +#!perl -T + +use strict; +use warnings; +use Test::Builder::Tester; +use Test::More; + +use Test::WWW::Mechanize; +use URI::file; + +BEGIN { + my $module = 'HTML::Tidy5 1.00'; + if ( not eval "use $module; 1;" ) { + plan skip_all => "$module is not installed, cannot test html_tidy_ok" if $@; + } + plan tests => 3; +} + +GOOD_GET: { + my $mech = Test::WWW::Mechanize->new; + isa_ok( $mech, 'Test::WWW::Mechanize' ); + + my $uri = URI::file->new_abs( 't/bad.html' )->as_string; + $mech->get_ok( $uri, 'Fetching the file from disk' ); + + test_out( "not ok 1 - checking HTML ($uri)" ); + test_fail( +6 ); + test_err( "# HTML::Tidy5 messages for $uri" ); + test_err( '# (1:1) Warning: missing <!DOCTYPE> declaration' ); + test_err( '# (8:33) Warning: discarding unexpected </b>' ); + test_err( '# (8:9) Warning: missing </a>' ); + test_err( '# 3 messages on the page' ); + $mech->html_tidy_ok( 'checking HTML' ); + test_test( 'Proper html_tidy_ok results' ); +} + +done_testing(); +exit 0;