From: Vincent Pit Date: Tue, 24 Mar 2015 02:20:46 +0000 (-0300) Subject: Forbid double quotes in code run by run_perl() X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=4eeb5afcf2cff2ebeeb8620b6b7f70dd54b7c3db;p=perl%2Fmodules%2FVPIT-TestHelpers.git Forbid double quotes in code run by run_perl() They are not portable to Windows. --- diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index 940d7f4..b8623c5 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -144,6 +144,10 @@ sub load_or_skip_all { sub run_perl { my $code = shift; + if ($code =~ /"/) { + die 'Double quotes in evaluated code are not portable'; + } + my ($SystemRoot, $PATH) = @ENV{qw}; my $ld_name = $Config::Config{ldlibpthname}; my $ldlibpth = $ENV{$ld_name}; diff --git a/t/30-run_perl.t b/t/30-run_perl.t index 2165197..077b58e 100644 --- a/t/30-run_perl.t +++ b/t/30-run_perl.t @@ -5,7 +5,7 @@ use warnings; use VPIT::TestHelpers; -use Test::More tests => 5; +use Test::More tests => 5 + 1; use Config; use File::Temp; @@ -66,3 +66,12 @@ for my $os (qw) { is $got, $exp, "run_perl preserving $os ENV vars"; } + +{ + local $@; + eval { + run_perl 'print "hello\n"'; + }; + like $@, qr/^Double quotes in evaluated code are not portable/, + 'croak on double quotes'; +}