From 27b7ed9159ff725b0ade5ebb7c249a5f57f7c21d Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Thu, 10 Sep 2020 10:29:06 +0200 Subject: [PATCH] ensure PATH for test is not too long, as that is incompatible with win2k --- t/make_executable.t | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/t/make_executable.t b/t/make_executable.t index 85b321c..058e1c0 100644 --- a/t/make_executable.t +++ b/t/make_executable.t @@ -11,7 +11,7 @@ use Cwd qw/cwd/; my @test_vals = ( 0, 1, 2, 3, -1, -2, 65535, 65536, 65537, 47, 100, 200, 255, 256, 257, 258, 511, 512, 513, -255, -256, -20012001 ); -plan($OSNAME eq 'MSWin32' ? ( tests => (($#test_vals+1)*5)+1 ) : ( skip_all => 'Only usable on Windows' )); +plan($OSNAME eq 'MSWin32' ? ( tests => (($#test_vals+1)*5)+2 ) : ( skip_all => 'Only usable on Windows' )); my $perl_in_fname = 'test_perl_source'; @@ -28,9 +28,25 @@ ok (-e "$batch_out_fname", qq{Executable file exists ("$batch_out_fname")}); my $int_max_8bit = 2**8; my $int_max_16bit = 2**16; +my $tmp_path = do { # keep PATH from going above 1023 chars (incompatible on win2k) + my $perl_path = $^X; + my $cmd_path = $ENV{ComSpec} || `where cmd`; # doesn't seem to work on all windows versions + my @path_fallbacks = grep /\Q$ENV{SystemRoot}\E|system32|winnt|windows/i, split $Config{path_sep}, $ENV{PATH}; + $_ =~ s/[\\\/][^\\\/]+$// for $perl_path, $cmd_path; # strip executable name + join $Config{path_sep}, @path_fallbacks, $cmd_path, $perl_path, cwd(); +}; + +{ + local $ENV{PATH} = $tmp_path; + my $test_out = `perl -e 1 2>&1`; + is $test_out, "", "perl execution with temp path works" + or print STDERR "make_executable.t tmp path: $tmp_path\n"; + print STDERR "make_executable.t PATH likely did not contain cmd.exe\n" + if !defined $test_out; +} + foreach my $input_val ( @test_vals ) { - my $cwd = cwd; - local $ENV{PATH} = join $Config{path_sep}, $cwd, $ENV{PATH}; + local $ENV{PATH} = $tmp_path; my $qx_output = q//; my $qx_retval = 0; my $error_level = 0;