]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make TestLib::perl2host more consistent and robust
authorAndrew Dunstan <andrew@dunslane.net>
Thu, 29 Jul 2021 16:15:03 +0000 (12:15 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Thu, 29 Jul 2021 16:16:50 +0000 (12:16 -0400)
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.

src/test/perl/TestLib.pm

index 26fbe08d4be82f05b768c3f20392f98aa83783a7..108f393774e6cab9fc6a4adda8e65394bf6aaf96 100644 (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
 available.
 
+The returned path uses forward slashes but has no trailing slash.
+
 =cut
 
 sub perl2host
@@ -313,10 +315,11 @@ sub perl2host
        if ($is_msys2)
        {
                # get absolute, windows type path
-               my $path = qx{cygpath -a -w "$subject"};
+               my $path = qx{cygpath -a -m "$subject"};
                if (!$?)
                {
                        chomp $path;
+                       $path =~ s!/$!!;
                        return $path if $path;
                }
                # 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.
        my $dir = qx{sh -c "pwd -W"};
        chomp $dir;
+       $dir =~ s!/$!!;
        chdir $here;
        return $dir . $leaf;
 }