From 7e698b486410e08e8120786f7c39f250bc4ee0bb Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 21 Feb 2012 01:34:04 +0100 Subject: [PATCH] t/50-cgi: optionally use Test::LongString to format failures Pretty-print string comparison to directly pinpoint differences instead of drowning us in full contents. --- t/50-cgi.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/50-cgi.t b/t/50-cgi.t index 111e112..58e36d1 100644 --- a/t/50-cgi.t +++ b/t/50-cgi.t @@ -5,6 +5,20 @@ use Cwd; use File::Spec; use Test::More; +eval { + require Test::LongString; + Test::LongString->import(max => 128); + + no warnings 'redefine'; # override module to not escape newlines + my $formatter = *Test::LongString::_display; + my $parent = \&{$formatter}; + *{$formatter} = sub { + my $s = &{$parent}; + $s =~ s/\Q\x{0a}/\n /g; # revert newline quoting + return $s; + }; +} or *is_string = \&is; # fallback to ugly unformatted is() + eval { require PerlIO::scalar }; plan skip_all => "PerlIO required (perl 5.8) to test PLP" if $@; @@ -57,7 +71,7 @@ sub plp_is { return; } $output =~ s{((?:.+\n)*)}{ join "", sort split /(?<=\n)/, $1 }e; # order headers - is($output, $expect, $test); + is_string($output, $expect, $test); } sub getwarning { -- 2.30.0