From: Dagfinn Ilmari Mannsåker Date: Mon, 5 May 2014 20:54:43 +0000 (+0100) Subject: Fix test failures when running under CATALYST_DEBUG. RT#95358 X-Git-Tag: 5.90065~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=c13f6e7ecb789a860ee01f163a5e4b66a4854186 Fix test failures when running under CATALYST_DEBUG. RT#95358 --- diff --git a/Changes b/Changes index 86c8a1f..fa58fa2 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ - Fix spelling, grammar and structural errors in POD - Remove redundant ->setup call in t/head_middleware.t RT#95361 + - Fix test failures when running under CATALYST_DEBUG. RT#95358 5.90064 - 2014-05-05 - Fix for mindless broken tests on Win32 (Haarg++). diff --git a/t/aggregate/live_engine_response_headers.t b/t/aggregate/live_engine_response_headers.t index a0663e1..6cf9fdc 100644 --- a/t/aggregate/live_engine_response_headers.t +++ b/t/aggregate/live_engine_response_headers.t @@ -37,8 +37,8 @@ foreach my $method (qw(HEAD GET)) { 'HEAD method content is empty' ); } elsif ( $method eq 'GET' ) { - # method name is echo'd back in content-body, which - # accounts for difference in content length. In normal + # method name is echo'd back in content-body (twice under debug), + # which accounts for difference in content length. In normal # cases the Content-Length should be the same regardless # of whether it's a GET or HEAD request. SKIP: @@ -46,8 +46,10 @@ foreach my $method (qw(HEAD GET)) { if ( $ENV{CATALYST_SERVER} ) { skip "Using remote server", 2; } + my $diff = TestApp->debug ? 2 : 1; is( $response->header('Content-Length'), - $content_length - 1, 'Response Header Content-Length' ); + $content_length - $diff, 'Response Header Content-Length' ) + or diag $response->content; is( length($response->content), $response->header('Content-Length'), 'GET method content' ); diff --git a/t/lib/TestLogger.pm b/t/lib/TestLogger.pm index f1dc7e6..6c1a26e 100644 --- a/t/lib/TestLogger.pm +++ b/t/lib/TestLogger.pm @@ -3,6 +3,7 @@ use strict; use warnings; our @LOGS; +our @ILOGS; our @ELOGS; sub new { @@ -14,6 +15,11 @@ sub debug { push(@LOGS, shift()); } +sub info { + shift; + push(@ILOGS, shift()); +} + sub warn { shift; push(@ELOGS, shift()); diff --git a/t/psgi-log.t b/t/psgi-log.t index e010d07..9e269c3 100644 --- a/t/psgi-log.t +++ b/t/psgi-log.t @@ -46,6 +46,8 @@ use HTTP::Request::Common; no Moose; } +my $cmp = TestApp->debug ? '>=' : '=='; + #subtest "psgi.errors" => sub { @@ -69,8 +71,8 @@ use HTTP::Request::Common; my $cb = shift; my $res = $cb->(GET "/log/debug"); my @logs = $handle->logs; - is(scalar(@logs), 1, "psgi.errors: one event output"); - like($logs[0], qr/debug$/, "psgi.errors: event matches test data"); + cmp_ok(scalar(@logs), $cmp, 1, "psgi.errors: one event output"); + like($logs[0], qr/debug$/m, "psgi.errors: event matches test data"); }; }; @@ -96,8 +98,9 @@ use HTTP::Request::Common; test_psgi $app, sub { my $cb = shift; my $res = $cb->(GET "/log/debug"); - is(scalar(@logs), 1, "psgix.logger: one event logged"); - is_deeply($logs[0], { level => 'debug', message => "debug" }, "psgix.logger: right stuff"); + cmp_ok(scalar(@logs), $cmp, 1, "psgix.logger: one event logged"); + is(scalar(grep { $_->{level} eq 'debug' and $_->{message} eq 'debug' } @logs), + 1, "psgix.logger: right stuff"); }; };