=item *
-Dependencies : none
+Dependencies :
+
+=over 8
+
+=item -
+
+L<File::Spec>
+
+=back
=item *
=item -
+C<run_perl_file $file>
+
+=item -
+
C<RUN_PERL_FAILED> (possibly prefixed by C<$p>)
=back
sub init_run_perl {
my $p = sanitize_prefix(shift);
+ # This is only required for run_perl_file(), so it is not needed for the
+ # threads feature which only calls run_perl() - don't forget to update its
+ # requirements if this ever changes.
+ require File::Spec;
+
return (
run_perl => \&run_perl,
+ run_perl_file => \&run_perl_file,
"${p}RUN_PERL_FAILED" => sub () { 'Could not execute perl subprocess' },
);
}
};
}
+sub run_perl_file {
+ my $file = shift;
+
+ $file = File::Spec->rel2abs($file);
+ unless (-e $file and -r _) {
+ die 'Could not run perl file';
+ }
+
+ fresh_perl_env {
+ my ($perl, @perl_args) = @_;
+ system { $perl } $perl, @perl_args, $file;
+ };
+}
+
=head2 C<capture>
=over 4
if (defined $pkg and defined $threadsafe_var) {
my $threadsafe;
+ # run_perl() doesn't actually require anything
my $stat = run_perl("require POSIX; require $pkg; exit($threadsafe_var ? POSIX::EXIT_SUCCESS() : POSIX::EXIT_FAILURE())");
if (defined $stat) {
require POSIX;
use VPIT::TestHelpers 'run_perl' => [ 'VTH' ];
-use Test::More tests => 5 + 2;
+use Test::More tests => 5 + 2 + 2;
use Config;
use File::Temp;
is $got, $exp, "run_perl preserving $os ENV vars";
}
+{
+ local $@;
+ my $stat = eval {
+ run_perl_file 't/testcases/run_perl_file.pl';
+ };
+ $stat = $stat >> 8 if defined $stat;
+ is $@, '', 'run_perl_file() does not croak';
+ is $stat, 123, 'run_perl_file() captures the exit value';
+}
+
{
local $@;
eval {