[Rt-commit] rt branch, 4.0/test-warnings, updated. rt-4.0.0-178-gff0bda7

Shawn Moore sartak at bestpractical.com
Tue May 3 13:27:07 EDT 2011


The branch, 4.0/test-warnings has been updated
       via  ff0bda731aed079cd0c3db54310a59316ac97c91 (commit)
      from  6130a77dc21e9d7518496d3c962249a1ab2b1693 (commit)

Summary of changes:
 t/api/template-simple.t |   56 +++++++++++++++++++++--------------------------
 1 files changed, 25 insertions(+), 31 deletions(-)

- Log -----------------------------------------------------------------
commit ff0bda731aed079cd0c3db54310a59316ac97c91
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue May 3 13:26:55 2011 -0400

    Use Test::Warn in t/api/template-simple.t too

diff --git a/t/api/template-simple.t b/t/api/template-simple.t
index 21f8d47..2848d00 100644
--- a/t/api/template-simple.t
+++ b/t/api/template-simple.t
@@ -2,6 +2,7 @@ use strict;
 use warnings;
 use RT;
 use RT::Test tests => 231;
+use Test::Warn;
 
 my $queue = RT::Queue->new(RT->SystemUser);
 $queue->Load("General");
@@ -126,19 +127,21 @@ SimpleTemplateTest(
     Output  => "test { \$Nonexistent }",
 );
 
-TemplateTest(
-    Content      => "\ntest { \$Ticket->Nonexistent }",
-    PerlOutput   => undef,
-    PerlWarnings => qr/RT::Ticket::Nonexistent Unimplemented/,
-    SimpleOutput => "test { \$Ticket->Nonexistent }",
-);
+warning_like {
+    TemplateTest(
+        Content      => "\ntest { \$Ticket->Nonexistent }",
+        PerlOutput   => undef,
+        SimpleOutput => "test { \$Ticket->Nonexistent }",
+    );
+} qr/RT::Ticket::Nonexistent Unimplemented/;
 
-TemplateTest(
-    Content      => "\ntest { \$Nonexistent->Nonexistent }",
-    PerlOutput   => undef,
-    PerlWarnings => qr/Can't call method "Nonexistent" on an undefined value/,
-    SimpleOutput => "test { \$Nonexistent->Nonexistent }",
-);
+warning_like {
+    TemplateTest(
+        Content      => "\ntest { \$Nonexistent->Nonexistent }",
+        PerlOutput   => undef,
+        SimpleOutput => "test { \$Nonexistent->Nonexistent }",
+    );
+} qr/Can't call method "Nonexistent" on an undefined value/;
 
 TemplateTest(
     Content      => "\ntest { \$Ticket->OwnerObj->Name }",
@@ -146,13 +149,14 @@ TemplateTest(
     SimpleOutput => "test { \$Ticket->OwnerObj->Name }",
 );
 
-TemplateTest(
-    Content      => "\ntest { *!( }",
-    SyntaxError  => 1,
-    PerlOutput   => undef,
-    PerlWarnings => qr/syntax error/,
-    SimpleOutput => "test { *!( }",
-);
+warning_like {
+    TemplateTest(
+        Content      => "\ntest { *!( }",
+        SyntaxError  => 1,
+        PerlOutput   => undef,
+        SimpleOutput => "test { *!( }",
+    );
+} qr/Template parsing error: syntax error/;
 
 TemplateTest(
     Content      => "\ntest { \$rtname ",
@@ -207,11 +211,6 @@ sub IndividualTemplateTest {
         @_,
     );
 
-    my $warnings;
-    local $SIG{__WARN__} = sub {
-        $warnings .= "@_";
-    } if $args{Warnings};
-
     my $t = RT::Template->new(RT->SystemUser);
     $t->Create(
         Name    => $args{Name},
@@ -247,10 +246,6 @@ sub IndividualTemplateTest {
     else {
         ok(!$ok, "expected a failure");
     }
-
-    if ($args{Warnings}) {
-        like($warnings, $args{Warnings}, "warnings matched");
-    }
 }
 
 sub TemplateTest {
@@ -262,9 +257,8 @@ sub TemplateTest {
 
         IndividualTemplateTest(
             %args,
-            Type     => $type,
-            Output   => $args{$type . 'Output'},
-            Warnings => $args{$type . 'Warnings'},
+            Type   => $type,
+            Output => $args{$type . 'Output'},
         );
     }
 }

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


More information about the Rt-commit mailing list