Fix test failures when running under CATALYST_DEBUG. RT#95358
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_response_headers.t
index 0d373c2..6cf9fdc 100644 (file)
@@ -1,5 +1,3 @@
-#!perl
-
 use strict;
 use warnings;
 
@@ -12,7 +10,7 @@ use HTTP::Request::Common;
 
 my $content_length;
 
-foreach my $method qw(HEAD GET) {
+foreach my $method (qw(HEAD GET)) {
     my $expected = join( ', ', 1 .. 10 );
 
     my $request = HTTP::Request::Common->can($method)
@@ -39,17 +37,19 @@ 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 if its a GET or HEAD request.
+        # of whether it's a GET or HEAD request.
         SKIP:
         {
             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' );