Author: timbo
Date: Wed Oct 25 03:50:53 2006
New Revision: 7974
Modified:
dbi/trunk/Changes
dbi/trunk/DBI.pm
dbi/trunk/t/40profile.t
Log:
Fixed t/40profile.t to be insensitive to small negative shifts in time thanks
to Jamie McCarthy.
Added some notes to swap_inner_handle docs.
Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes (original)
+++ dbi/trunk/Changes Wed Oct 25 03:50:53 2006
@@ -8,6 +8,8 @@
Fixed checks for weaken to work with early 5.8.x versions
Fixed DBD::Proxy handling of some methods, including commit and rollback.
+ Fixed t/40profile.t to be insensitive to small negative shifts in time
+ thanks to Jamie McCarthy.
Fixed to work with current 'bleadperl' (~5.9.5) thanks to Steve Peters.
Users of Perl >= 5.9.5 will require DBI >= 1.53.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Wed Oct 25 03:50:53 2006
@@ -3257,13 +3257,38 @@
method swaps the inner hashes between two handles. The $h1 and $h2
handles still point to the same tied hashes, but what those hashes
are tied to has been swapped. In effect $h1 I<becomes> $h2 and
-vice-versa. This is powerful stuff. Use with care.
+vice-versa. This is powerful stuff, expect problems. Use with care.
As a small safety measure, the two handles, $h1 and $h2, have to
share the same parent unless $allow_reparent is true.
The swap_inner_handle() method was added in DBI 1.44.
+Here's a quick kind of 'diagram' as a worked example to help think about what's
+happening:
+
+ Original state:
+ dbh1o -> dbh1i
+ sthAo -> sthAi(dbh1i)
+ dbh2o -> dbh2i
+
+ swap_inner_handle dbh1o with dbh2o:
+ dbh2o -> dbh1i
+ sthAo -> sthAi(dbh1i)
+ dbh1o -> dbh2i
+
+ create new sth from dbh1o:
+ dbh2o -> dbh1i
+ sthAo -> sthAi(dbh1i)
+ dbh1o -> dbh2i
+ sthBo -> sthBi(dbh2i)
+
+ swap_inner_handle sthAo with sthBo:
+ dbh2o -> dbh1i
+ sthBo -> sthAi(dbh1i)
+ dbh1o -> dbh2i
+ sthAo -> sthBi(dbh2i)
+
=back
Modified: dbi/trunk/t/40profile.t
==============================================================================
--- dbi/trunk/t/40profile.t (original)
+++ dbi/trunk/t/40profile.t Wed Oct 25 03:50:53 2006
@@ -133,28 +133,31 @@
ok(@$data == 7);
ok((grep { defined($_) } @$data) == 7);
ok((grep { DBI::looks_like_number($_) } @$data) == 7);
-ok((grep { $_ >= 0 } @$data) == 7) or warn "profile data:
[EMAIL PROTECTED]";
my ($count, $total, $first, $shortest, $longest, $time1, $time2) = @$data;
-if ($shortest < 0) {
- my $sys = "$Config{archname} $Config{osvers}"; # sparc-linux
2.4.20-2.3sparcsmp
- warn "Time went backwards at some point during the test on this $sys
system!\n";
- warn "Perhaps you have time sync software (like NTP) that adjusted the
clock\n";
- warn "backwards by more than $shortest seconds during the test. PLEASE
RETRY.\n";
- # Don't treat very small negative amounts as a failure - it's always been
due
- # due to NTP or buggy multiprocessor systems.
- $shortest = 0 if $shortest > -0.008;
-}
ok($count > 3);
ok($total > $first);
ok($total > $longest) or warn "total $total > longest $longest: failed\n";
ok($longest > 0) or warn "longest $longest > 0: failed\n"; # XXX theoretically
not reliable
ok($longest > $shortest);
-ok($time1 > 0);
-ok($time2 > 0);
+ok($time1 >= $^T);
+ok($time2 >= $^T);
+ok($time1 <= $time2);
my $next = time + 1;
ok($next > $time1) or warn "next $next > first $time1: failed\n";
ok($next > $time2) or warn "next $next > last $time2: failed\n";
-ok($time1 <= $time2);
+if ($shortest < 0) {
+ my $sys = "$Config{archname} $Config{osvers}"; # ie sparc-linux
2.4.20-2.3sparcsmp
+ warn <<EOT;
+Time went backwards at some point during the test on this $sys system!
+Perhaps you have time sync software (like NTP) that adjusted the clock
+by more than $shortest seconds during the test.
+Also some multiprocessor systems, and some virtualization systems can exhibit
+this kind of clock behaviour. Please retry.
+EOT
+ # don't treat small negative values as failure
+ $shortest = 0 if $shortest > -0.008;
+}
+
my $tmp = sanitize_tree($dbh->{Profile});
$tmp->{Data}{$sql}[0] = -1; # make test insensitive to local file count