From: Vincent Pit Date: Mon, 1 Sep 2014 12:57:05 +0000 (+0200) Subject: Use run_perl() from VPIT::TestHelpers X-Git-Tag: rt98525~1 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c248088d736c15d3d88ed92a3e7d475f80a9d415;p=perl%2Fmodules%2FVariable-Magic.git Use run_perl() from VPIT::TestHelpers This updates VPIT::TestHelpers to 4fb18792. --- diff --git a/t/17-ctl.t b/t/17-ctl.t index 19dd864..c9dd4ca 100644 --- a/t/17-ctl.t +++ b/t/17-ctl.t @@ -5,6 +5,9 @@ use warnings; use Test::More tests => 4 * 8 + 4 * (2 * 6 + 1) + 10 + 1 + 1; +use lib 't/lib'; +use VPIT::TestHelpers; + use Variable::Magic qw; sub expect { @@ -342,17 +345,6 @@ eval q{BEGIN { like $@, expect('tomato', undef, "\nBEGIN.*"), 'die in BEGIN in eval triggers hints hash destructor'; -sub run_perl { - my $code = shift; - - 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 { diff --git a/t/lib/VPIT/TestHelpers.pm b/t/lib/VPIT/TestHelpers.pm index 3d545e8..91de044 100644 --- a/t/lib/VPIT/TestHelpers.pm +++ b/t/lib/VPIT/TestHelpers.pm @@ -3,9 +3,12 @@ package VPIT::TestHelpers; use strict; use warnings; +use Config (); + my %exports = ( load_or_skip => \&load_or_skip, load_or_skip_all => \&load_or_skip_all, + run_perl => \&run_perl, skip_all => \&skip_all, ); @@ -102,6 +105,21 @@ sub load_or_skip_all { return $loaded; } +sub run_perl { + my $code = shift; + + my ($SystemRoot, $PATH) = @ENV{qw}; + my $ld_name = $Config::Config{ldlibpthname}; + my $ldlibpth = $ENV{$ld_name}; + + local %ENV; + $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot; + $ENV{PATH} = $PATH if $^O eq 'cygwin' and defined $PATH; + $ENV{$ld_name} = $ldlibpth if $^O eq 'android' and defined $ldlibpth; + + system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code; +} + package VPIT::TestHelpers::Guard; sub new {