/home/.cpanm/work/1759492321.34807/Template-Toolkit-3.102/t
#!/usr/bin/perl #============================================================= -*-perl-*- # # t/zz-plugin-leak-gh-213.t # # Testcase from aka GH #213 # view https://github.com/abw/Template2/pull/213 # # Written by Nicolas R. <atoomic@cpan.org> # #======================================================================== # stolen from t/filter.t need to refactor package Tie::File2Str; sub TIEHANDLE { my ( $class, $textref ) = @_; bless $textref, $class; } sub PRINT { my $self = shift; $$self .= join( '', @_ ); } package main; use lib qw( t/lib ./lib ../lib ../blib/arch ./test ); use Template; use Test::More; plan skip_all => "Broken on older perls. We need to sort this out once everything is passing"; use File::Temp qw(tempfile tempdir); plan skip_all => "Developer test only - set RELEASE_TESTING=1" unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ); plan tests => 3; # ------- t1.txt - checkleak template my $t1 = <<'EOT'; [%- USE Echo -%] [% FILTER $Echo %]foo[% END %] [% FILTER $Echo %]bar[% END %] EOT # ------- checkleak.pm a super checkleak custom filter my $plugin_echo = <<'EOT'; package Template::Plugin::Echo; use base qw(Template::Plugin::Filter); sub filter { my ($self, $text) = @_; return $text . $text; } 1; EOT my $template_tmpdir = tempdir( CLEANUP => 1 ); write_text( qq[$template_tmpdir/t1.txt], $t1 ); my $plugindir = tempdir( CLEANUP => 1 ); my $plugin_pm = qq[$plugindir/Template/Plugin/Echo.pm]; # pretty ugly but only run by authors... mkdir("$plugindir/Template") && mkdir("$plugindir/Template/Plugin"); die q[Failed to create plugindir] unless -d "$plugindir/Template/Plugin"; write_text( $plugin_pm, $plugin_echo ); unshift @INC, $plugindir; ok eval { do $plugin_pm; 1 }, "can load Template::Plugin::checkleak" or die "Failed to load Template::Plugin::checkleak - $@"; # chdir to our temporary folder with templates chdir($template_tmpdir) or die; my $tt = Template->new( { 'PLUGIN_BASE' => $plugindir } ); my $out; my $stderr; { local *STDERR; tie( *STDERR, "Tie::File2Str", \$stderr ); $tt->process( 't1.txt', {}, \$out ) || print STDERR "Error: " . $tt->error(); } # make sure we can process the template without any issues # the original bug was doing a weaken on the plugin itself.. # resulting in not being able to load it a second time is $out, <<'EXPECT', "Template processed correctly using Plugin checkleak twice"; foofoo barbar EXPECT is $stderr, undef, "no warning from process 'Reference is already weak'"; done_testing; exit; END { chdir '/' } # cd out of the temp dir. sub write_text { # could also use File::Slurper::write_file .... my ( $file, $content ) = @_; open( my $fh, '>', $file ) or die $!; print {$fh} $content; close($fh); }
.
Edit
..
Edit
README
Edit
anycase.t
Edit
args.t
Edit
assert.t
Edit
base.t
Edit
binop.t
Edit
block.t
Edit
block_duplicate.t
Edit
blocks.t
Edit
capture.t
Edit
case.t
Edit
chomp.t
Edit
compile1.t
Edit
compile2.t
Edit
compile3.t
Edit
compile4.t
Edit
compile5.t
Edit
config.t
Edit
constants.t
Edit
context.t
Edit
datafile.t
Edit
date.t
Edit
date_offset.t
Edit
date_utf8.t
Edit
debug.t
Edit
directive.t
Edit
directry.t
Edit
document.t
Edit
dumper.t
Edit
error.t
Edit
evalperl.t
Edit
exception.t
Edit
factory.t
Edit
file.t
Edit
fileline.t
Edit
filter.t
Edit
foreach.t
Edit
format.t
Edit
html.t
Edit
image.t
Edit
include.t
Edit
iterator.t
Edit
leak.t
Edit
lib
Edit
list.t
Edit
load_order_vmethods_stash.t
Edit
macro.t
Edit
math.t
Edit
math_rand.t
Edit
meta.t
Edit
mtime-zero.t
Edit
object.t
Edit
outline.t
Edit
outline_line.t
Edit
output.t
Edit
parser.t
Edit
parser2.t
Edit
plugins.t
Edit
plusfile.t
Edit
pod.t
Edit
prefix.t
Edit
proc.t
Edit
process-relative.t
Edit
process.t
Edit
process_dir.t
Edit
provider.t
Edit
ref.t
Edit
scalar.t
Edit
service.t
Edit
skel.t
Edit
stash-xs-unicode.t
Edit
stash-xs.t
Edit
stash.t
Edit
stashc.t
Edit
stop.t
Edit
strcat.t
Edit
strict.t
Edit
string.t
Edit
switch.t
Edit
table.t
Edit
tags.t
Edit
template.t
Edit
test
Edit
text.t
Edit
throw.t
Edit
tiedhash.t
Edit
trace_vars.t
Edit
try.t
Edit
unicode.t
Edit
url.t
Edit
vars.t
Edit
varsv1.t
Edit
view.t
Edit
vmethods
Edit
while.t
Edit
wrap.t
Edit
wrapper.t
Edit
zz-plugin-cycle.t
Edit
zz-plugin-leak-gh-213.t
Edit
zz-plugin-leak-rt-46691.t
Edit
zz-plugin-leak.t
Edit
zz-pmv.t
Edit
zz-pod-coverage.t
Edit
zz-pod-kwalitee.t
Edit
zz-stash-xs-leak.t
Edit
zz-url2.t
Edit