mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Consolidate methods for translating a Perl path to a Windows path.
This fixes some TAP suites when using msys Perl and a builddir located in an msys mount point other than "/". For example, builddir=/c/pg exhibited the problem, since /c/pg falls in mount point "/c". Back-patch to 9.6, where tests first started to perform such translations. In back branches, offer both new and old APIs. Reviewed by Andrew Dunstan. Discussion: https://postgr.es/m/20190610045838.GA238501@rfd.leadboat.com
This commit is contained in:
@ -11,6 +11,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use Config;
|
||||
use Cwd;
|
||||
use Exporter 'import';
|
||||
use File::Basename;
|
||||
use File::Spec;
|
||||
@ -145,6 +146,33 @@ sub tempdir_short
|
||||
return File::Temp::tempdir(CLEANUP => 1);
|
||||
}
|
||||
|
||||
# Translate a Perl file name to a host file name. Currently, this is a no-op
|
||||
# except for the case of Perl=msys and host=mingw32. The subject need not
|
||||
# exist, but its parent directory must exist.
|
||||
sub perl2host
|
||||
{
|
||||
my ($subject) = @_;
|
||||
return $subject unless $Config{osname} eq 'msys';
|
||||
my $here = cwd;
|
||||
my $leaf;
|
||||
if (chdir $subject)
|
||||
{
|
||||
$leaf = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$leaf = '/' . basename $subject;
|
||||
my $parent = dirname $subject;
|
||||
chdir $parent or die "could not chdir \"$parent\": $!";
|
||||
}
|
||||
|
||||
# this odd way of calling 'pwd -W' is the only way that seems to work.
|
||||
my $dir = qx{sh -c "pwd -W"};
|
||||
chomp $dir;
|
||||
chdir $here;
|
||||
return $dir . $leaf;
|
||||
}
|
||||
|
||||
sub system_log
|
||||
{
|
||||
print("# Running: " . join(" ", @_) . "\n");
|
||||
|
Reference in New Issue
Block a user