From 65a58eed625dc58022e6c8c67b91fd9e0e7fe99a Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 7 Oct 2009 17:48:31 -0500 Subject: [PATCH] Revert "Fix a bug with session counting for WEBGUI_TEST_DEBUG" This reverts commit f53af08e2720990ee7451fcc9e563ff7a79de2ba. --- t/lib/WebGUI/Test.pm | 52 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index aec8c8097..04b6eb9d2 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -74,8 +74,6 @@ our @EXPORT_OK = qw(session config); my $CLASS = __PACKAGE__; my @guarded; -our @checkCount; -our %initCounts; sub import { our $CONFIG_FILE = $ENV{ WEBGUI_CONFIG }; @@ -101,22 +99,30 @@ sub import { if ($ENV{WEBGUI_TEST_DEBUG}) { ##Offset Sessions, and Scratch by 1 because 1 will exist at the start - @checkCount = ( - Sessions => userSession => 1, - Scratch => userSessionScratch => 1, - Users => users => 0, - Groups => groups => 0, - mailQ => mailQueue => 0, - Tags => assetVersionTag => 0, - Assets => assetData => 0, - Workflows => Workflow => 0, - Carts => cart => 0, + my @checkCount = ( + Sessions => 'userSession', + Scratch => 'userSessionScratch', + Users => 'users', + Groups => 'groups', + mailQ => 'mailQueue', + Tags => 'assetVersionTag', + Assets => 'assetData', + Workflows => 'Workflow', ); - for ( my $i = 0; $i < @checkCount; $i += 3) { + my %initCounts; + for ( my $i = 0; $i < @checkCount; $i += 2) { my ($label, $table) = @checkCount[$i, $i+1]; $initCounts{$table} = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); } push @guarded, Scope::Guard->new(sub { + for ( my $i = 0; $i < @checkCount; $i += 2) { + my ($label, $table) = @checkCount[$i, $i+1]; + my $quant = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table); + my $delta = $quant - $initCounts{$table}; + if ($delta) { + $CLASS->builder->diag(sprintf '%-10s: %4d (delta %+d)', $label, $quant, $delta); + } + } }); } @@ -133,22 +139,10 @@ sub cleanup { pop @guarded while @guarded; - if ( my $session = $CLASS->session ) { - $session->var->end; - my $db = delete $session->{_db}; - $session->close; - ##Do this absolutely last, so that there's no session or other object pieces left over. - if ($ENV{WEBGUI_TEST_DEBUG}) { - for ( my $i = 0; $i < @checkCount; $i += 3) { - my ($label, $table, $offset) = @checkCount[$i, $i+1, $i+2]; - my $quant = $db->quickScalar('SELECT COUNT(*) FROM ' . $table); - my $delta = $quant - $initCounts{$table} + $offset; - if ($delta) { - $CLASS->builder->diag(sprintf '%-10s: %4d (delta %+d)', $label, $quant, $delta); - } - } - } - $db->disconnect; + if ( $SESSION ) { + $SESSION->var->end; + $SESSION->close; + undef $SESSION; } }