]> git.vpit.fr Git - perl/modules/VPIT-TestHelpers.git/blobdiff - t/30-run_perl.t
Turn run_perl() into a feature
[perl/modules/VPIT-TestHelpers.git] / t / 30-run_perl.t
index b71f7be0b592cacd2540bfa5e1917030fdf1a21e..2238fb76838cf0f79e8d87d7f35237a16e7a5071 100644 (file)
@@ -3,25 +3,29 @@
 use strict;
 use warnings;
 
-use VPIT::TestHelpers;
+use VPIT::TestHelpers 'run_perl' => [ 'VTH' ];
 
-use Test::More tests => 4;
+use Test::More tests => 5 + 2;
 
 use Config;
 use File::Temp;
 
 my $filename = '/tmp/run_perl_test';
 
+my $guard = VPIT::TestHelpers::Guard->new(sub { unlink $filename });
+
 my $code = "open my \$fh, q[>], q[$filename] or die \$!; for my \$key (sort keys %ENV) { print \$fh qq[\$key:\$ENV{\$key}\n] } close \$fh";
 
 my $ld_path = $Config::Config{ldlibpthname};
 
 my %expected_vars = (
  'MSWin32' => [ qw<SystemRoot> ],
- 'android' => [ $ld_path       ],
+ 'android' => [                ],
  'cygwin'  => [ qw<PATH>       ],
+ 'darwin'  => [                ],
  'linux'   => [                ],
 );
+push @$_, $ld_path for values %expected_vars;
 
 my @all_vars = do {
  my %uniq;
@@ -35,7 +39,7 @@ my @ignored_vars = qw<
  __CF_USER_TEXT_ENCODING
 >;
 
-for my $os (qw<MSWin32 android cygwin linux>) {
+for my $os (qw<MSWin32 android darwin cygwin linux>) {
  1 while unlink $filename;
 
  local $^O  = $os;
@@ -62,3 +66,17 @@ for my $os (qw<MSWin32 android cygwin linux>) {
 
  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';
+}
+
+{
+ my $msg = VTH_RUN_PERL_FAILED;
+ like $msg, qr/^Could not execute/, 'RUN_PERL_FAILED error message';
+}