From 85bc66764b118bcbd7510d13d13d34e426836af5 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 1 Apr 2025 00:22:25 +0200 Subject: [PATCH] PathTools: check Config values early before chdir In a perl core build, the @INC paths will be relative. If you change directories before loading all of the files needed, they won't be able to be found. Config.pm loads some of its values at runtime, so if they are accessed after a chdir, it may fail. One of the PathTools tests was relying on the fact that Config_heavy.pl would be loaded by Test::More, before it did a chdir. Newer Test::More won't do that, so the test would fail. Accessing the required Config values early will prevent this failure. This same issue is unlikely to impact anything outside core, as it requires the perl core paths in @INC to be relative paths, which is normally not the case. --- dist/PathTools/Cwd.pm | 2 +- dist/PathTools/lib/File/Spec.pm | 2 +- dist/PathTools/lib/File/Spec/AmigaOS.pm | 2 +- dist/PathTools/lib/File/Spec/Cygwin.pm | 2 +- dist/PathTools/lib/File/Spec/Epoc.pm | 2 +- dist/PathTools/lib/File/Spec/Functions.pm | 2 +- dist/PathTools/lib/File/Spec/Mac.pm | 2 +- dist/PathTools/lib/File/Spec/OS2.pm | 2 +- dist/PathTools/lib/File/Spec/Unix.pm | 2 +- dist/PathTools/lib/File/Spec/VMS.pm | 2 +- dist/PathTools/lib/File/Spec/Win32.pm | 2 +- dist/PathTools/t/cwd_enoent.t | 6 ++++-- 12 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dist/PathTools/Cwd.pm b/dist/PathTools/Cwd.pm index 7876f301bf03..b8828b6817ec 100644 --- a/dist/PathTools/Cwd.pm +++ b/dist/PathTools/Cwd.pm @@ -3,7 +3,7 @@ use strict; use Exporter; -our $VERSION = '3.92'; +our $VERSION = '3.94'; my $xs_version = $VERSION; $VERSION =~ tr/_//d; diff --git a/dist/PathTools/lib/File/Spec.pm b/dist/PathTools/lib/File/Spec.pm index 78d60007b475..a6a5e7c76318 100644 --- a/dist/PathTools/lib/File/Spec.pm +++ b/dist/PathTools/lib/File/Spec.pm @@ -4,7 +4,7 @@ use strict; # Keep $VERSION consistent in all *.pm files in this distribution, including # Cwd.pm. -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; my %module = ( diff --git a/dist/PathTools/lib/File/Spec/AmigaOS.pm b/dist/PathTools/lib/File/Spec/AmigaOS.pm index c6eb3af92b72..2a95123cd5eb 100644 --- a/dist/PathTools/lib/File/Spec/AmigaOS.pm +++ b/dist/PathTools/lib/File/Spec/AmigaOS.pm @@ -3,7 +3,7 @@ package File::Spec::AmigaOS; use strict; require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/lib/File/Spec/Cygwin.pm b/dist/PathTools/lib/File/Spec/Cygwin.pm index 140e9ea53ec1..2c97c81cc417 100644 --- a/dist/PathTools/lib/File/Spec/Cygwin.pm +++ b/dist/PathTools/lib/File/Spec/Cygwin.pm @@ -3,7 +3,7 @@ package File::Spec::Cygwin; use strict; require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/lib/File/Spec/Epoc.pm b/dist/PathTools/lib/File/Spec/Epoc.pm index 61fcb97ecb97..a95fb3b06956 100644 --- a/dist/PathTools/lib/File/Spec/Epoc.pm +++ b/dist/PathTools/lib/File/Spec/Epoc.pm @@ -2,7 +2,7 @@ package File::Spec::Epoc; use strict; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; require File::Spec::Unix; diff --git a/dist/PathTools/lib/File/Spec/Functions.pm b/dist/PathTools/lib/File/Spec/Functions.pm index fe0c22043af6..94f3126b6285 100644 --- a/dist/PathTools/lib/File/Spec/Functions.pm +++ b/dist/PathTools/lib/File/Spec/Functions.pm @@ -3,7 +3,7 @@ package File::Spec::Functions; use File::Spec; use strict; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; require Exporter; diff --git a/dist/PathTools/lib/File/Spec/Mac.pm b/dist/PathTools/lib/File/Spec/Mac.pm index 7f8c3b3c726c..4dc2e19498d5 100644 --- a/dist/PathTools/lib/File/Spec/Mac.pm +++ b/dist/PathTools/lib/File/Spec/Mac.pm @@ -4,7 +4,7 @@ use strict; use Cwd (); require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/lib/File/Spec/OS2.pm b/dist/PathTools/lib/File/Spec/OS2.pm index a9fde0dc3e0d..77a950936b20 100644 --- a/dist/PathTools/lib/File/Spec/OS2.pm +++ b/dist/PathTools/lib/File/Spec/OS2.pm @@ -4,7 +4,7 @@ use strict; use Cwd (); require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/lib/File/Spec/Unix.pm b/dist/PathTools/lib/File/Spec/Unix.pm index 0269061301ac..96d1d6c76174 100644 --- a/dist/PathTools/lib/File/Spec/Unix.pm +++ b/dist/PathTools/lib/File/Spec/Unix.pm @@ -3,7 +3,7 @@ package File::Spec::Unix; use strict; use Cwd (); -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; =head1 NAME diff --git a/dist/PathTools/lib/File/Spec/VMS.pm b/dist/PathTools/lib/File/Spec/VMS.pm index 62d5893aca8f..3730d6d0f9bd 100644 --- a/dist/PathTools/lib/File/Spec/VMS.pm +++ b/dist/PathTools/lib/File/Spec/VMS.pm @@ -4,7 +4,7 @@ use strict; use Cwd (); require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/lib/File/Spec/Win32.pm b/dist/PathTools/lib/File/Spec/Win32.pm index 63dad8f56ffe..297a75724e2a 100644 --- a/dist/PathTools/lib/File/Spec/Win32.pm +++ b/dist/PathTools/lib/File/Spec/Win32.pm @@ -5,7 +5,7 @@ use strict; use Cwd (); require File::Spec::Unix; -our $VERSION = '3.93'; +our $VERSION = '3.94'; $VERSION =~ tr/_//d; our @ISA = qw(File::Spec::Unix); diff --git a/dist/PathTools/t/cwd_enoent.t b/dist/PathTools/t/cwd_enoent.t index 05b30b37ded4..fcd0008d06e0 100644 --- a/dist/PathTools/t/cwd_enoent.t +++ b/dist/PathTools/t/cwd_enoent.t @@ -10,6 +10,8 @@ if($^O eq "cygwin") { # This test skipping should be removed when the Cygwin bug is fixed. plan skip_all => "getcwd() fails to fail on Cygwin [perl #132733]"; } +my $prefix = $Config{prefix}; +my $osvers = $Config{osvers}; my $tmp = tempdir(CLEANUP => 1); unless(mkdir("$tmp/testdir") && chdir("$tmp/testdir") && rmdir("$tmp/testdir")){ @@ -24,11 +26,11 @@ foreach my $type (qw(regular perl)) { SKIP: { skip "_perl_abs_path() not expected to work", 4 if $type eq "perl" && - !(($Config{prefix} =~ m/\//) && $^O ne "cygwin"); + !(($prefix =~ m/\//) && $^O ne "cygwin"); # https://github.com/Perl/perl5/issues/16525 # https://bugs.dragonflybsd.org/issues/3250 - my @vlist = ($Config{osvers} =~ /(\d+)/g); + my @vlist = ($osvers =~ /(\d+)/g); my $osver = sprintf("%d%03d", map { defined() ? $_ : '0' } @vlist[0,1]); skip "getcwd() doesn't fail on non-existent directories on this platform", 4 if $type eq 'regular' && $^O eq 'dragonfly' && $osver < 6002;