[Rt-commit] rt branch, 4.0/web-installer-warnings, created. rt-4.0.5-93-g0b5adf4

Alex Vandiver alexmv at bestpractical.com
Wed Mar 21 19:39:12 EDT 2012


The branch, 4.0/web-installer-warnings has been created
        at  0b5adf4051078b0012aa2ac301e26438aca2b0ea (commit)

- Log -----------------------------------------------------------------
commit 0b5adf4051078b0012aa2ac301e26438aca2b0ea
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 21 19:31:01 2012 -0400

    Catch warnings to STDERR when loading rt-server, for installer tests
    
    The web installer tests introduced in f855c79 use the functionality
    provided in 61dd5be, to load the 'sbin/rt-server' file, which sets up
    the web installer if the database is missing.  Unfortunately, this file
    prints to STDERR, which makes the test no longer warnings-clean.
    
    Though this particular case prints to STDERR directly (rather than
    calling warn), changing it would not improve matters, as the warnings
    handler which Plack::Middleware::Test::StashWarnings installs only
    happens at request time, much too late to catch the warning.
    
    Explicitly catch the warning printed to STDERR by temporarily
    redirecting STDERR to an in-memory filehandle, and recording its
    contents as a warning by hand.  As this API was introduced in
    Plack::Middleware::Test::StashWarnings 0.06, bump the dependency
    accordingly.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index a0aae72..7d69dd6 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1313,6 +1313,10 @@ sub test_app {
 
     my $app;
 
+    my $warnings = "";
+    open( my $warn_fh, ">", \$warnings );
+    local *STDERR = $warn_fh;
+
     if ($server_opt{variant} and $server_opt{variant} eq 'rt-server') {
         $app = do {
             my $file = "$RT::SbinPath/rt-server";
@@ -1330,7 +1334,8 @@ sub test_app {
     }
 
     require Plack::Middleware::Test::StashWarnings;
-    $app = Plack::Middleware::Test::StashWarnings->wrap($app);
+    my $stashwarnings = Plack::Middleware::Test::StashWarnings->new;
+    $app = $stashwarnings->wrap($app);
 
     if ($server_opt{basic_auth}) {
         require Plack::Middleware::Auth::Basic;
@@ -1342,6 +1347,10 @@ sub test_app {
             }
         );
     }
+
+    close $warn_fh;
+    $stashwarnings->add_warning( $warnings ) if $warnings;
+
     return $app;
 }
 
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 03c813b..8328a25 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -288,7 +288,7 @@ Test::Builder 0.90 # needed for is_passing
 Test::MockTime
 Log::Dispatch::Perl
 Test::WWW::Mechanize::PSGI
-Plack::Middleware::Test::StashWarnings
+Plack::Middleware::Test::StashWarnings 0.06
 Test::LongString
 .
 
diff --git a/t/web/installer.t b/t/web/installer.t
index cde9359..4dc82df 100644
--- a/t/web/installer.t
+++ b/t/web/installer.t
@@ -10,6 +10,9 @@ use RT::Test
 
 my ($base, $m) = RT::Test->started_ok;
 
+$m->warning_like(qr/If this is a new installation of RT/,
+                 "Got startup warning");
+
 $m->get_ok($base);
 like $m->uri, qr/Install/, 'at installer';
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list