From: Vincent Pit Date: Mon, 1 Sep 2014 12:40:35 +0000 (+0200) Subject: Add run_perl() X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c5c8848158218fd477eb23f81f58ac221dacd7f9;p=perl%2Fmodules%2FVPIT-TestHelpers.git Add run_perl() --- diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index 3d545e8..30c6bc0 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -6,6 +6,7 @@ use warnings; 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 +103,17 @@ sub load_or_skip_all { return $loaded; } +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; +} + package VPIT::TestHelpers::Guard; sub new {