From a72ec0e7502747b3010eb4c6a0ea5353d88de1d1 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Tue, 21 Aug 2012 15:44:33 -0400 Subject: [PATCH] ignore cycles that are taken care of in Template::Provider#DESTROY --- t/tt_plugin_lite_app.t | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/t/tt_plugin_lite_app.t b/t/tt_plugin_lite_app.t index 715c815..bc93d63 100644 --- a/t/tt_plugin_lite_app.t +++ b/t/tt_plugin_lite_app.t @@ -43,8 +43,17 @@ $t->get_ok('/')->status_is(200) ->content_like(qr/test123456/); $t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/); -if(eval q{ use Test::Memory::Cycle; 1 }) +if(eval q{ use Devel::Cycle; 1 }) { - Test::Memory::Cycle::memory_cycle_ok(app); -} - + Devel::Cycle::find_cycle(app, sub { + my $arg = shift; + # Template::Provider (from which M::P::T::Provider inherits) has some cycles which are freed manaully by + # its DESTROY method, so we skip reporting those cycles. + unless(scalar(scalar(grep { ref($_->[2]) eq 'Mojolicious::Plugin::TtRenderer::Provider' && $_->[1] =~ /^(HEAD|TAIL|LOOKUP)$/ } @$arg)) > 0) + { + #use YAML (); + #diag YAML::Dump([ map { [ $_->[0], $_->[1], ref($_->[2]), ref($_->[3]) ] } @$arg ]); + fail('Cycle found') + } + }); +}; \ No newline at end of file