silence warnings in tests
Graham Knop [Sun, 21 Oct 2018 02:36:56 +0000 (04:36 +0200)]
16 files changed:
t/abort-chain-1.t
t/abort-chain-2.t
t/abort-chain-3.t
t/accept_context_regression.t
t/aggregate/unit_core_component.t
t/aggregate/unit_core_mvc.t
t/aggregate/unit_core_setup_log.t
t/arg_constraints.t
t/bad_warnings.t
t/class_traits.t
t/class_traits_CAR_bug.t
t/execute_exception.t
t/lib/TestDataHandlers/Controller/Root.pm
t/live_component_controller_context_closure.t
t/useless_set_headers.t
t/utf_incoming.t

index d471f9a..849bd54 100644 (file)
@@ -34,7 +34,7 @@ BEGIN {
     package TestApp;
     $INC{'TestApp.pm'} = __FILE__;
     use Catalyst;
-    __PACKAGE__->setup;
+    __PACKAGE__->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'TestApp';
index af45ccf..7b45f48 100644 (file)
@@ -35,7 +35,7 @@ BEGIN {
     $INC{'TestApp.pm'} = __FILE__;
     use Catalyst;
     __PACKAGE__->config(abort_chain_on_error_fix => 1);
-    __PACKAGE__->setup;
+    __PACKAGE__->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'TestApp';
index 979249c..83fe703 100644 (file)
@@ -35,7 +35,7 @@ BEGIN {
     $INC{'TestApp.pm'} = __FILE__;
     use Catalyst;
     __PACKAGE__->config(abort_chain_on_error_fix => 0);
-    __PACKAGE__->setup;
+    __PACKAGE__->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'TestApp';
index 916281a..2d1a2d3 100644 (file)
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 use Test::More;
 
-{
+BEGIN {
   package MyApp::Model::AcceptContext;
   use base 'Catalyst::Model';
 
@@ -12,7 +12,9 @@ use Test::More;
   }
 
   $INC{'MyApp/Model/AcceptContext.pm'} = __FILE__;
+}
 
+BEGIN {
   package MyApp::Controller::Root;
   use base 'Catalyst::Controller';
 
@@ -22,7 +24,9 @@ use Test::More;
   }
 
   $INC{'MyApp/Controller/Root.pm'} = __FILE__;
+}
 
+BEGIN {
   package MyApp;
   use Catalyst;
 
@@ -31,10 +35,8 @@ use Test::More;
 
 use Catalyst::Test 'MyApp';
 
-my ($res, $c) = ctx_request('/test_model');
+my ($res, $c) = ctx_request('/root/test_model');
 
 ok $res;
 
-
 done_testing;
-
index 69ac6c0..31830a6 100644 (file)
@@ -14,7 +14,7 @@ my @complist = map { "MyApp::$_"; } qw/C::Controller M::Model V::View/;
   __PACKAGE__->components({ map { ($_, $_) } @complist });
 
   # this is so $c->log->warn will work
-  __PACKAGE__->setup_log;
+  __PACKAGE__->setup_log('fatal');
 }
 
 is(MyApp->comp('MyApp::V::View'), 'MyApp::V::View', 'Explicit return ok');
index ed31e7d..86ed667 100644 (file)
@@ -21,7 +21,7 @@ my @complist =
     __PACKAGE__->components->{'MyMVCTestApp::Model::Test::Object'} = $thingie;
 
     # allow $c->log->warn to work
-    __PACKAGE__->setup_log;
+    __PACKAGE__->setup_log('fatal');
 }
 
 {
index fb73297..6795047 100644 (file)
@@ -9,7 +9,17 @@ sub mock_app {
     my $name = shift;
     my $meta = Moose->init_meta( for_class => $name );
     $meta->superclasses('Catalyst');
-    return $meta->name;
+
+    $meta->add_after_method_modifier('log', sub {
+        my ($self, $log) = @_;
+        if ($log) {
+            open my $err_fh, '>', \(my $err_out)
+                or die 'unable to open in memory buffer';
+            $log->psgienv({ 'psgi.errors' => $err_fh });
+        }
+    });
+
+    return $name;
 }
 
 sub test_log_object {
index 2103bf2..05278d1 100644 (file)
@@ -262,7 +262,7 @@ BEGIN {
   package MyApp;
   use Catalyst;
 
-  MyApp->setup;
+  MyApp->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'MyApp';
index b7bc17d..1b914f6 100644 (file)
@@ -52,7 +52,7 @@ my $error;
 
   $SIG{__WARN__} = sub { $error = shift };
 
-  MyApp->setup;
+  MyApp->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'MyApp';
index 1a49b33..8730822 100644 (file)
@@ -49,6 +49,17 @@ BEGIN {
   sub d { 'd' }
 }
 
+BEGIN {
+  package TestApp::Controller::Root;
+  $INC{'TestApp/Controller/Root.pm'} = __FILE__;
+
+  use Moose;
+
+  BEGIN { extends 'Catalyst::Controller' };
+
+  sub root :Path('/') {}
+}
+
 {
   package TestApp;
   $INC{'TestApp.pm'} = __FILE__;
index de3e6aa..2e9743b 100644 (file)
@@ -50,6 +50,17 @@ BEGIN {
 
 }
 
+BEGIN {
+  package TestApp::Controller::Root;
+  $INC{'TestApp/Controller/Root.pm'} = __FILE__;
+
+  use Moose;
+
+  BEGIN { extends 'Catalyst::Controller' };
+
+  sub root :Path('/') {}
+}
+
 {
   package TestApp;
   $INC{'TestApp.pm'} = __FILE__;
index b880b06..da03682 100644 (file)
@@ -43,7 +43,7 @@ use HTTP::Request::Common;
   use Catalyst;
 
   MyApp->config(show_internal_actions=>1);
-  MyApp->setup;
+  MyApp->setup('-Log=fatal');
 }
 
 use Catalyst::Test 'MyApp';
index 3aa45f4..f079a0f 100644 (file)
@@ -2,6 +2,8 @@ package TestDataHandlers::Controller::Root;
 
 use base 'Catalyst::Controller';
 
+sub root :Path('/') {}
+
 sub test_json :Local {
     my ($self, $c) = @_;
     $c->res->body($c->req->body_data->{message});
index 72ddb15..69fa504 100644 (file)
@@ -14,7 +14,7 @@ use FindBin;
 use lib "$FindBin::Bin/lib";
 
 BEGIN { $::setup_leakchecker = 1 }
-local $SIG{__WARN__} = sub { return if $_[0] =~ /Unhandled type: GLOB/; warn $_[0] };
+local $SIG{__WARN__} = sub { return if $_[0] =~ /Unhandled type: (GLOB|REGEXP)/; warn $_[0] };
 use Catalyst::Test 'TestApp';
 
 {
index 78873fb..104c174 100644 (file)
@@ -37,7 +37,7 @@ use HTTP::Request::Common;
 
   sub debug { 1 }
 
-  __PACKAGE__->log(TestAppStats::Log->new);
+  __PACKAGE__->log(TestAppStats::Log->new('warn'));
 
   after 'finalize' => sub {
     my ($c) = @_;
index d21137d..39f5c51 100644 (file)
@@ -234,7 +234,7 @@ use Scalar::Util ();
   package MyApp;
   use Catalyst;
 
-  Test::More::ok(MyApp->setup, 'setup app');
+  Test::More::ok(MyApp->setup('-Log=fatal'), 'setup app');
 }
 
 ok my $psgi = MyApp->psgi_app, 'build psgi app';