[Rt-commit] rt branch, 4.0/silence-test-warnings, created. rt-4.0.8-182-g82f86c7

Alex Vandiver alexmv at bestpractical.com
Mon Nov 26 13:34:18 EST 2012


The branch, 4.0/silence-test-warnings has been created
        at  82f86c79896ca5fd7ed513ab5862e1926e67ca1f (commit)

- Log -----------------------------------------------------------------
commit 0acc888003e6f701793562816316eb3865a8a9d7
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Nov 14 16:43:23 2012 -0800

    Catch specific warnings emitted by three test files
    
    Tests should now be warnings clean once again.

diff --git a/t/api/squish.t b/t/api/squish.t
index 5961536..4b0fc5f 100644
--- a/t/api/squish.t
+++ b/t/api/squish.t
@@ -1,11 +1,16 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test nodb => 1, tests => 7;
+use RT::Test nodb => 1, tests => undef;
+use Test::Warn;
 
 use RT::Squish;
 
-my $squish = RT::Squish->new();
+my $squish;
+warning_like {
+    $squish = RT::Squish->new();
+} [qr/implement/], "warns this is only an abstract base class";
+
 for my $method ( qw/Content ModifiedTime ModifiedTimeString Key/ ) {
     can_ok($squish, $method);
 }
@@ -14,3 +19,5 @@ ok( (time()-$squish->ModifiedTime) <= 2, 'ModifiedTime' );
 
 use RT::Squish::CSS;
 can_ok('RT::Squish::CSS', 'Style');
+
+done_testing;
diff --git a/t/customfields/ip.t b/t/customfields/ip.t
index 1e39e2c..3ab7fbd 100644
--- a/t/customfields/ip.t
+++ b/t/customfields/ip.t
@@ -2,7 +2,8 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 73;
+use RT::Test tests => undef;
+use Test::Warn;
 
 my ( $baseurl, $agent ) = RT::Test->started_ok;
 ok( $agent->login, 'log in' );
@@ -264,7 +265,9 @@ diag "create a ticket with an IP of 10.0.0.1 and search for doesn't match '10.0.
     ok( $id, "created first ticket $id" );
 
     my $tickets = RT::Tickets->new($RT::SystemUser);
-    $tickets->FromSQL("id=$id AND CF.{IP} NOT LIKE '10.0.0.'");
+    warning_like {
+        $tickets->FromSQL("id=$id AND CF.{IP} NOT LIKE '10.0.0.'");
+    } [qr/not a valid IPAddress/], "caught warning about valid IP address";
 
     SKIP: {
         skip "partical ip parse causes ambiguity", 1;
@@ -282,3 +285,6 @@ diag "test the operators in search page" if $ENV{'TEST_VERBOSE'};
     ok( $op, "found 'CF.{IP}'Op" );
     is_deeply( [ $op->possible_values ], [ '=', '!=', '<', '>' ], 'op values' );
 }
+
+undef $agent;
+done_testing;
diff --git a/t/customfields/ipv6.t b/t/customfields/ipv6.t
index 0d4075f..f97420e 100644
--- a/t/customfields/ipv6.t
+++ b/t/customfields/ipv6.t
@@ -2,7 +2,8 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 102;
+use RT::Test tests => undef;
+use Test::Warn;
 
 my ( $baseurl, $agent ) = RT::Test->started_ok;
 ok( $agent->login, 'log in' );
@@ -241,7 +242,9 @@ diag "create a ticket with an IP of abcd:23:: and search for doesn't match 'abcd
     ok( $id, "created first ticket $id" );
 
     my $tickets = RT::Tickets->new($RT::SystemUser);
-    $tickets->FromSQL("id=$id AND CF.{IP} NOT LIKE 'abcd:23'");
+    warning_like {
+        $tickets->FromSQL("id=$id AND CF.{IP} NOT LIKE 'abcd:23'");
+    } [qr/not a valid IPAddress/], "caught warning about IPAddress";
 
     SKIP: {
         skip "partical ip parse can causes ambiguity", 1;
@@ -249,3 +252,5 @@ diag "create a ticket with an IP of abcd:23:: and search for doesn't match 'abcd
     }
 }
 
+undef $agent;
+done_testing;

commit 82f86c79896ca5fd7ed513ab5862e1926e67ca1f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Nov 26 13:06:53 2012 -0500

    Provide a Log::Dispatch->warn which works on Log::Dispatch 2.23
    
    Though Log::Dispatch 2.23 added the ->warn alias for ->warning, until
    version 2.30 it failed to correctly canonicalize the level internally,
    and thus failed to ever usefully generate output.  All of the warnings
    added in 0acc888 thus only appear on Log::Dispatch 2.30 and above, due
    to this bug -- and consequently the newly-added 'warning_like' tests
    fail with earlier versions.
    
    Rather than increase the minimum Log::Dispatch version during a stable
    series, provide a thin shim for ->warn which calls ->warning, which
    works as expected.

diff --git a/lib/RT.pm b/lib/RT.pm
index 063f7f7..5d3f557 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -312,6 +312,13 @@ sub InitLogging {
     InitSignalHandlers();
 }
 
+{   # Work around bug in Log::Dispatch < 2.30, wherein ->warn() does not
+    # usefully propagate out, unlike ->warning()
+    package Log::Dispatch;
+    no warnings 'redefine';
+    sub warn { shift->warning(@_) }
+}
+
 sub InitSignalHandlers {
 
 # Signal handlers

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


More information about the Rt-commit mailing list