6 use VPIT::TestHelpers 'run_perl' => [ 'VTH' ];
8 use Test::More tests => 5 + 2;
13 my $filename = '/tmp/run_perl_test';
15 my $guard = VPIT::TestHelpers::Guard->new(sub { unlink $filename });
17 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";
19 my $ld_path = $Config::Config{ldlibpthname};
22 'MSWin32' => [ qw<SystemRoot> ],
24 'cygwin' => [ qw<PATH> ],
28 unless ($^O eq 'darwin') {
29 push @$_, $ld_path for values %expected_vars;
34 grep !$uniq{$_}++, map @$_, values %expected_vars;
36 push @all_vars, 'DUMMY';
38 my @ignored_vars = qw<
39 VERSIONER_PERL_PREFER_32_BIT
40 VERSIONER_PERL_VERSION
41 __CF_USER_TEXT_ENCODING
43 push @ignored_vars, $ld_path if $^O eq 'darwin';
45 for my $os (qw<MSWin32 android darwin cygwin linux>) {
46 1 while unlink $filename;
49 @ENV{@all_vars} = @all_vars;
58 open my $fh, '<', $filename;
63 %subprocess_env = map { split /:/, $_, 2 } @lines;
66 delete @subprocess_env{@ignored_vars};
68 my $got = join "\n", sort keys %subprocess_env;
69 my $exp = join "\n", sort @{ $expected_vars{$os} || [] };
71 is $got, $exp, "run_perl preserving $os ENV vars";
77 run_perl 'print "hello\n"';
79 like $@, qr/^Double quotes in evaluated code are not portable/,
80 'croak on double quotes';
84 my $msg = VTH_RUN_PERL_FAILED;
85 like $msg, qr/^Could not execute/, 'RUN_PERL_FAILED error message';