From: Vincent Pit Date: Thu, 9 Apr 2015 14:29:15 +0000 (-0300) Subject: Introduce fresh_perl_env() and make run_perl() use it X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0bcc011a0cf1879908fd93fdfeb3a31d66657424;p=perl%2Fmodules%2FVPIT-TestHelpers.git Introduce fresh_perl_env() and make run_perl() use it --- diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index 9054314..7dfd15e 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -142,12 +142,8 @@ sub load_or_skip_all { return $loaded; } -sub run_perl { - my $code = shift; - - if ($code =~ /"/) { - die 'Double quotes in evaluated code are not portable'; - } +sub fresh_perl_env (&) { + my $handler = shift; my ($SystemRoot, $PATH) = @ENV{qw}; my $ld_name = $Config::Config{ldlibpthname}; @@ -166,7 +162,20 @@ sub run_perl { } } - system { $perl } $perl, '-T', map("-I$_", @INC), '-e', $code; + return $handler->($perl, '-T', map("-I$_", @INC)); +} + +sub run_perl { + my $code = shift; + + if ($code =~ /"/) { + die 'Double quotes in evaluated code are not portable'; + } + + fresh_perl_env { + my ($perl, @perl_args) = @_; + system { $perl } $perl, @perl_args, '-e', $code; + }; } sub init_capture {