[Catalyst-commits] r8617 - in Catalyst-Runtime/5.80/trunk:
lib/Catalyst t
jhannah at dev.catalyst.perl.org
jhannah at dev.catalyst.perl.org
Tue Nov 18 21:29:46 GMT 2008
Author: jhannah
Date: 2008-11-18 21:29:45 +0000 (Tue, 18 Nov 2008)
New Revision: 8617
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm
Catalyst-Runtime/5.80/trunk/t/unit_stats.t
Log:
Bug patch. The bug is that if you have any profile() calls with a
begin => but no end => and you call ->report() multiple
times, profile() will throw garbage items into the Tree::Simple.
By removing the map() from Stats.pm the bug no longer occurs.
I added a test item which fails until the Stats.pm patch is applied.
To see the bug in action, uncomment the print scalar($stats->report);
line I added without the Stats.pm patch applied. You'll see ugly blank
lines show up in the report().
You can also see that begin => with no end => works fine without
the map() code. The map actually breaks it, it doesn't fix anything as
far as I can tell.
Possibly cleaner would be to patch profile() so that the garbage can
never happen, but I spent several hours on that and couldn't track it
down. This solves the problem and all tests pass. And removes code that
does nothing.
Cheers,
jhannah
jay(at)jays(dot)net
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm 2008-11-17 23:31:42 UTC (rev 8616)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm 2008-11-18 21:29:45 UTC (rev 8617)
@@ -87,10 +87,6 @@
sub report {
my $self = shift;
- # close any remaining open nodes
- map { $self->profile(end => $_->getNodeValue->{action}) }
- (reverse @{ $self->stack })[1 .. $#{$self->stack}];
-
my $t = Text::SimpleTable->new( [ 62, 'Action' ], [ 9, 'Time' ] );
my @results;
$self->tree->traverse(
Modified: Catalyst-Runtime/5.80/trunk/t/unit_stats.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_stats.t 2008-11-17 23:31:42 UTC (rev 8616)
+++ Catalyst-Runtime/5.80/trunk/t/unit_stats.t 2008-11-18 21:29:45 UTC (rev 8617)
@@ -69,6 +69,10 @@
$stats->profile(comment => "interleave 2");
push(@expected, [ 4, "- interleave 2", 0.2, 0 ]);
+ $fudge_t[1] = 550000;
+ $stats->profile(begin => "begin with no end");
+ push(@expected, [ 4, "begin with no end", 0.05, 1 ]);
+
$fudge_t[1] = 600000; # end badly nested block time
$stats->profile(end => "badly nested block 1");
@@ -85,6 +89,8 @@
my @report = $stats->report;
is_deeply(\@report, \@expected, "report");
+ # print scalar($stats->report);
+
is ($stats->elapsed, 14, "elapsed");
}
More information about the Catalyst-commits
mailing list