[Bps-public-commit] r13409 - in Shipwright/trunk: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jun 18 17:13:06 EDT 2008


Author: sunnavy
Date: Wed Jun 18 17:13:06 2008
New Revision: 13409

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Test.pm

Log:
 r13544 at sunnavys-mb:  sunnavy | 2008-06-19 05:07:22 +0800
 refactor a bit to reduce redundancy


Modified: Shipwright/trunk/lib/Shipwright/Test.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Test.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Test.pm	Wed Jun 18 17:13:06 2008
@@ -118,31 +118,29 @@
     my $repo    = shift;
     my $cmd     = shift;
     my $exp     = shift;
-    my $msg     = shift;
+    my $msg     = shift || "@$cmd out";
     my $exp_err = shift;
-    my $msg_err = shift;
+    my $msg_err = shift || "@$cmd err";
 
     unshift @$cmd, $^X, '-MDevel::Cover' if devel_cover_enabled;
 
     require Test::More;
     my ( $out, $err ) = Shipwright::Util->run( $cmd, 1 );    # ingnore failure
 
-    if ( defined $exp ) {
-        if ( ref $exp eq 'Regexp' ) {
-            Test::More::like( $out, $exp, $msg );
-        }
-        else {
-            Test::More::is( $out, $exp, $msg );
-        }
-    }
+    _test_cmd( $out, $exp, $msg ) if defined $exp;
+    _test_cmd( $err, $exp_err, $msg_err ) if defined $exp_err;
+}
 
-    if ( defined $exp_err ) {
-        if ( ref $exp_err eq 'Regexp' ) {
-            Test::More::like( $err, $exp_err, $msg_err );
-        }
-        else {
-            Test::More::is( $err, $exp_err, $msg_err );
-        }
+sub _test_cmd {
+    my $out = shift;
+    my $exp = shift;
+    my $msg = shift;
+
+    if ( ref $exp eq 'Regexp' ) {
+        Test::More::like( $out, $exp, $msg );
+    }
+    else {
+        Test::More::is( $out, $exp, $msg );
     }
 }
 



More information about the Bps-public-commit mailing list