X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=blobdiff_plain;f=t%2F17-ctl.t;h=88345409e64d6c50d6e6fd54ac507f745a3e2089;hp=c9dd4ca6426c7149d400e3550689c5156756fcd8;hb=34c317825d931337c0d5cdc6b365ca9a16906310;hpb=4a19e38d1c3cae3504a5d2dbbca0bd483280f1f7 diff --git a/t/17-ctl.t b/t/17-ctl.t index c9dd4ca..8834540 100644 --- a/t/17-ctl.t +++ b/t/17-ctl.t @@ -6,7 +6,7 @@ use warnings; use Test::More tests => 4 * 8 + 4 * (2 * 6 + 1) + 10 + 1 + 1; use lib 't/lib'; -use VPIT::TestHelpers; +use VPIT::TestHelpers 'capture'; use Variable::Magic qw; @@ -345,41 +345,15 @@ eval q{BEGIN { like $@, expect('tomato', undef, "\nBEGIN.*"), 'die in BEGIN in eval triggers hints hash destructor'; -my $has_capture_tiny = do { - local $@; - eval { - require Capture::Tiny; - Capture::Tiny->VERSION('0.08'); - } -}; -if ($has_capture_tiny) { - local $@; - my $output = eval { - Capture::Tiny::capture_merged(sub { run_perl <<' CODE' }); -print STDOUT "pants\n"; -print STDERR "trousers\n"; - CODE - }; - unless (defined $output and $output =~ /pants/ and $output =~ /trousers/) { - $has_capture_tiny = 0; - } -} -if ($has_capture_tiny) { - defined and diag "Using Capture::Tiny $_" for $Capture::Tiny::VERSION; -} - -SKIP: -{ +SKIP: { my $count = 1; - skip 'No working Capture::Tiny is installed'=> $count unless $has_capture_tiny; - - my $output = Capture::Tiny::capture_merged(sub { run_perl <<' CODE' }); + my ($stat, $out, $err) = capture_perl <<' CODE'; use Variable::Magic qw; { BEGIN { $^H |= 0x020000; cast %^H, wizard free => sub { die q[cucumber] } } } CODE - skip 'Test code didn\'t run properly' => $count unless defined $output; - like $output, expect('cucumber', '-e', "\nExecution(?s:.*)"), - 'die in free callback at compile time and not in eval string'; + skip CAPTURE_PERL_FAILED($out) => $count unless defined $stat; + like $err, expect('cucumber', '-e', "\nExecution(?s:.*)"), + 'die in free callback at compile time and not in eval string'; --$count; } @@ -389,14 +363,13 @@ SKIP: { my $count = 1; - skip 'No nice uvar magic for this perl' => $count unless VMG_UVAR; - skip 'No working Capture::Tiny is installed'=> $count unless $has_capture_tiny; + skip 'No nice uvar magic for this perl' => $count unless VMG_UVAR; - my $output = Capture::Tiny::capture_merged(sub { run_perl <<' CODE' }); + my ($stat, $out, $err) = capture_perl <<' CODE'; use Variable::Magic qw; BEGIN { cast %derp::, wizard fetch => sub { die q[raddish] } } derp::hlagh() CODE - skip 'Test code didn\'t run properly' => $count unless defined $output; - like $output, expect('raddish', '-e', "\nExecution(?s:.*)"), - 'die in free callback at compile time and not in eval string'; + skip CAPTURE_PERL_FAILED($out) => $count unless defined $stat; + like $err, expect('raddish', '-e', "\nExecution(?s:.*)"), + 'die in free callback at compile time and not in eval string'; --$count; }