Author: timbo
Date: Wed Aug 22 09:32:32 2007
New Revision: 9866

Modified:
   dbi/trunk/MANIFEST
   dbi/trunk/lib/DBD/Gofer/Transport/Base.pm
   dbi/trunk/t/86gofer_fail.t

Log:
Fix knock-on effects of changing an error message.


Modified: dbi/trunk/MANIFEST
==============================================================================
--- dbi/trunk/MANIFEST  (original)
+++ dbi/trunk/MANIFEST  Wed Aug 22 09:32:32 2007
@@ -62,7 +62,6 @@
 lib/DBI/Util/_accessor.pm       A cut-down version of Class::Accessor::Fast
 lib/DBI/W32ODBC.pm             An experimental DBI emulation layer for 
Win32::ODBC
 lib/Win32/DBIODBC.pm           An experimental Win32::ODBC emulation layer for 
DBI
-goferperf.pl                    A performance test utility for DBD::Gofer
 t/01basics.t
 t/02dbidrv.t
 t/03handle.t

Modified: dbi/trunk/lib/DBD/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer/Transport/Base.pm   (original)
+++ dbi/trunk/lib/DBD/Gofer/Transport/Base.pm   Wed Aug 22 09:32:32 2007
@@ -135,7 +135,7 @@
 
     if (not defined $retry) {
         my $errstr = $response->errstr || '';
-        $retry = 1 if $errstr =~ m/fake error induced by DBI_GOFER_RANDOM/;
+        $retry = 1 if $errstr =~ m/induced by DBI_GOFER_RANDOM/;
     }
 
     if (not defined $retry) {

Modified: dbi/trunk/t/86gofer_fail.t
==============================================================================
--- dbi/trunk/t/86gofer_fail.t  (original)
+++ dbi/trunk/t/86gofer_fail.t  Wed Aug 22 09:32:32 2007
@@ -43,7 +43,7 @@
 ($fails, $dbh) = trial_impact("fail=100%,do", 10, "", sub { $_->do("set 
foo=1") });
 is $fails, 100, 'should fail 100% of the time';
 ok   $@, '$@ should be set';
-like $@, '/fake error induced by DBI_GOFER_RANDOM/';
+like $@, '/fake error from do method induced by DBI_GOFER_RANDOM/';
 ok   $dbh->errstr, 'errstr should be set';
 like $dbh->errstr, '/DBI_GOFER_RANDOM/', 'errstr should contain 
DBI_GOFER_RANDOM';
 ok !$dbh->{go_response}->executed_flag_set, 'go_response executed flag should 
be false';
@@ -53,11 +53,11 @@
 srand(42); # try to limit occasional failures (effect will vary by platform 
etc)
 
 sub trial_impact {
-    my ($spec, $count, $dsn_attr, $code) = @_;
+    my ($spec, $count, $dsn_attr, $code, $verbose) = @_;
     local $ENV{DBI_GOFER_RANDOM} = $spec;
     my $dbh = dbi_connect("policy=rush;$dsn_attr");
     local $_ = $dbh;
-    my $fail_percent = percentage_exceptions(200, $code);
+    my $fail_percent = percentage_exceptions(200, $code, $verbose);
     return $fail_percent unless wantarray;
     return ($fail_percent, $dbh);
 }
@@ -150,15 +150,19 @@
 }
 
 sub percentage_exceptions {
-    my ($count, $sub) = @_;
+    my ($count, $sub, $verbose) = @_;
     my $i = $count;
     my $exceptions = 0;
     while ($i--) {
         eval { $sub->() };
+        warn sprintf("percentage_exceptions $i: %s\n", $@|| $DBI::errstr || 
'')  if $verbose;
         if ($@) {
             die "Unexpected failure: $@" unless $@ =~ /DBI_GOFER_RANDOM/;
             ++$exceptions;
         }
     }
+    warn sprintf "percentage_exceptions %f/%f*100 = %f\n",
+        $exceptions, $count, $exceptions/$count*100
+        if $verbose;
     return $exceptions/$count*100;
 }

Reply via email to