Skip to content

Commit bad1067

Browse files
committed
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.
1 parent 91f9861 commit bad1067

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/test/perl/TestLib.pm

+5-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ except for the case of Perl=msys and host=mingw32. The subject need not
304304
exist, but its parent or grandparent directory must exist unless cygpath is
305305
available.
306306
307+
The returned path uses forward slashes but has no trailing slash.
308+
307309
=cut
308310

309311
sub perl2host
@@ -313,10 +315,11 @@ sub perl2host
313315
if ($is_msys2)
314316
{
315317
# get absolute, windows type path
316-
my $path = qx{cygpath -a -w "$subject"};
318+
my $path = qx{cygpath -a -m "$subject"};
317319
if (!$?)
318320
{
319321
chomp $path;
322+
$path =~ s!/$!!;
320323
return $path if $path;
321324
}
322325
# fall through if this didn't work.
@@ -342,6 +345,7 @@ sub perl2host
342345
# this odd way of calling 'pwd -W' is the only way that seems to work.
343346
my $dir = qx{sh -c "pwd -W"};
344347
chomp $dir;
348+
$dir =~ s!/$!!;
345349
chdir $here;
346350
return $dir . $leaf;
347351
}

0 commit comments

Comments
 (0)