X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F17-ctl.t;h=2adf60de8a858301b17a5fe621cb35163e1d906b;hb=d86c036207e622521bd725d7be7829d55ffd71f3;hp=bedfdb0428b440eeec3b80c8fb3279e6b0cb0f63;hpb=cf48e6bb084037da1980bde10e21dca795fd84d0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/17-ctl.t b/t/17-ctl.t index bedfdb0..2adf60d 100644 --- a/t/17-ctl.t +++ b/t/17-ctl.t @@ -5,7 +5,7 @@ use warnings; use Test::More tests => 4 * 8 + 10 + 1 + 1; -use Variable::Magic qw/wizard cast VMG_UVAR/; +use Variable::Magic qw; sub expect { my ($name, $where, $suffix) = @_; @@ -216,25 +216,41 @@ like $@, expect('tomato', undef, "\nBEGIN.*"), sub run_perl { my $code = shift; - my $SystemRoot = $ENV{SystemRoot}; + my ($SystemRoot, $PATH) = @ENV{qw}; local %ENV; $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot; + $ENV{PATH} = $PATH if $^O eq 'cygwin' and defined $PATH; system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code; } -my $has_capture_tiny = do { local $@; eval 'use Capture::Tiny 0.08 (); 1' }; +my $has_capture_tiny = do { + local $@; + eval 'use Capture::Tiny 0.08 (); 1' +}; +if ($has_capture_tiny) { + my $output = 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: { my $count = 1; - skip 'Capture::Tiny 0.08 is not installed' => $count unless $has_capture_tiny; + skip 'No working Capture::Tiny is installed'=> $count unless $has_capture_tiny; my $output = Capture::Tiny::capture_merged(sub { run_perl <<' CODE' }); -use Variable::Magic qw/wizard cast/; { BEGIN { $^H |= 0x020000; cast %^H, wizard free => sub { die q[cucumber] } } } +use Variable::Magic qw; { BEGIN { $^H |= 0x020000; cast %^H, wizard free => sub { die q[cucumber] } } } CODE - skip 'Test code didn\'t run properly' => 1 unless defined $output; + 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'; --$count; @@ -246,20 +262,14 @@ SKIP: { my $count = 1; - skip 'No nice uvar magic for this perl' => $count unless VMG_UVAR; - skip 'Capture::Tiny 0.08 is not installed' => $count unless $has_capture_tiny; + skip 'No nice uvar magic for this perl' => $count unless VMG_UVAR; + skip 'No working Capture::Tiny is installed'=> $count unless $has_capture_tiny; my $output = Capture::Tiny::capture_merged(sub { run_perl <<' CODE' }); -use Variable::Magic qw/wizard cast/; BEGIN { cast %::, wizard fetch => sub { die q[salsify] } } hlagh() +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; - my $suffix = "\nExecution(?s:.*)"; - if ($] >= 5.011005) { - $suffix = "(?:\nsalsify at -e line \\d+.){12}" . $suffix; - } elsif ($] >= 5.011) { - $suffix = "(?:\nsalsify at -e line \\d+.){3}" . $suffix; - } - like $output, expect('salsify', '-e', $suffix), - 'die in free callback at compile time and not in eval string'; + like $output, expect('raddish', '-e', "\nExecution(?s:.*)"), + 'die in free callback at compile time and not in eval string'; --$count; }