Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

Commit

Permalink
Hide warnings in test output
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Sep 14, 2017
1 parent 49ec2ea commit 295f561
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions t/parse-errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use warnings;

use Test::Exception;
use Test::More tests => 2;
use Test::More tests => 4;

use HTML::Tidy;

Expand All @@ -15,9 +15,19 @@ my $errbuf = do {
readline(*DATA);
};

my $ret = $tidy->_parse_errors('fake_filename.html', $errbuf, "\n");
is( $ret, 1, 'encountered 1 parsing error' );
is( scalar @{$tidy->{messages}}, 7, 'got 7 messages when parsing errors' );
CATCH_A_WARNING: {
my $stashed_warning;
my $ncalls = 0;
local $SIG{__WARN__} = sub { $stashed_warning = shift; ++$ncalls; };

my $ret = $tidy->_parse_errors('fake_filename.html', $errbuf, "\n");
is( $ret, 1, 'encountered 1 parsing error' );
is( scalar @{$tidy->{messages}}, 7, 'got 7 messages when parsing errors' );

# Check our warnings.
is( $ncalls, 1, 'Warning should have been called exactly once' );
like( $stashed_warning, qr/HTML::Tidy: Unknown error type: FAKE_ERROR_TYPE at/, 'Expected warning' );
}

__DATA__
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
Expand Down

0 comments on commit 295f561

Please sign in to comment.