From: Peter Rabbitson Date: Mon, 6 Sep 2010 17:20:45 +0000 (+0200) Subject: Fix 5.6 fail (scalarref open not supported) X-Git-Tag: v0.00305~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c97607df18cd1cf0dcab75a4edc801fcc94fd48;p=p5sagit%2FLog-Contextual.git Fix 5.6 fail (scalarref open not supported) --- diff --git a/t/simplelogger.t b/t/simplelogger.t index f9fd708..793c24d 100644 --- a/t/simplelogger.t +++ b/t/simplelogger.t @@ -1,6 +1,7 @@ use strict; use warnings; +use File::Temp; use Log::Contextual::SimpleLogger; use Log::Contextual qw{:log set_logger} => -logger => Log::Contextual::SimpleLogger->new({levels => [qw{debug}]}); @@ -22,13 +23,16 @@ ok(eval { log_error { die 'this should live' }; 1}, 'error does not get called') ok(eval { log_fatal { die 'this should live' }; 1}, 'fatal does not get called'); { - my $cap; - local *STDERR = do { open my $fh, '>', \$cap; $fh }; + my $tempfile = File::Temp->new (UNLINK => 1, TEMPLATE => 'stderrXXXXXX'); + my $fn = fileno ($tempfile); + open (STDERR, ">&$fn") or die $!; + log_debug { 'frew' }; - log_debug { 'frew' }; - is($cap, "[debug] frew\n", 'SimpleLogger outputs to STDERR correctly'); + my $out = do { local @ARGV = $tempfile; <> }; + is($out, "[debug] frew\n", 'SimpleLogger outputs to STDERR correctly'); } + my $response; my $l2 = Log::Contextual::SimpleLogger->new({ levels => [qw{trace debug info warn error fatal}],