1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-06 19:59:18 +03:00

Make TestLib::perl2host more consistent and robust

Sometimes cygpath has been observed to return a path with a trailing
slash. That can cause problems, Also, make "cygpath" usage
consistent with "pwd -W" with respect to the use of forward slashes.

Backpatch to release 14 where the current code was introduced.
This commit is contained in:
Andrew Dunstan 2021-07-29 12:15:03 -04:00
parent 67445deb7e
commit 68011e17d0
No known key found for this signature in database
GPG Key ID: 99FA7FCB59FC3B81

View File

@ -304,6 +304,8 @@ except for the case of Perl=msys and host=mingw32. The subject need not
exist, but its parent or grandparent directory must exist unless cygpath is exist, but its parent or grandparent directory must exist unless cygpath is
available. available.
The returned path uses forward slashes but has no trailing slash.
=cut =cut
sub perl2host sub perl2host
@ -313,10 +315,11 @@ sub perl2host
if ($is_msys2) if ($is_msys2)
{ {
# get absolute, windows type path # get absolute, windows type path
my $path = qx{cygpath -a -w "$subject"}; my $path = qx{cygpath -a -m "$subject"};
if (!$?) if (!$?)
{ {
chomp $path; chomp $path;
$path =~ s!/$!!;
return $path if $path; return $path if $path;
} }
# fall through if this didn't work. # fall through if this didn't work.
@ -342,6 +345,7 @@ sub perl2host
# this odd way of calling 'pwd -W' is the only way that seems to work. # this odd way of calling 'pwd -W' is the only way that seems to work.
my $dir = qx{sh -c "pwd -W"}; my $dir = qx{sh -c "pwd -W"};
chomp $dir; chomp $dir;
$dir =~ s!/$!!;
chdir $here; chdir $here;
return $dir . $leaf; return $dir . $leaf;
} }