Skip to content

Commit 6121ba9

Browse files
committed
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
1 parent df098c3 commit 6121ba9

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/test/perl/PostgresNode.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ our @EXPORT = qw(
103103
our ($use_tcp, $test_localhost, $test_pghost, $last_host_assigned,
104104
$last_port_assigned, @all_nodes);
105105

106-
# Windows path to virtual file system root
107-
106+
# For backward compatibility only.
108107
our $vfs_path = '';
109108
if ($Config{osname} eq 'msys')
110109
{
@@ -854,7 +853,7 @@ standby_mode=on
854853
sub enable_restoring
855854
{
856855
my ($self, $root_node) = @_;
857-
my $path = $vfs_path . $root_node->archive_dir;
856+
my $path = TestLib::perl2host($root_node->archive_dir);
858857
my $name = $self->name;
859858

860859
print "### Enabling WAL restore for node \"$name\"\n";
@@ -882,7 +881,7 @@ standby_mode = on
882881
sub enable_archiving
883882
{
884883
my ($self) = @_;
885-
my $path = $vfs_path . $self->archive_dir;
884+
my $path = TestLib::perl2host($self->archive_dir);
886885
my $name = $self->name;
887886

888887
print "### Enabling WAL archiving for node \"$name\"\n";

src/test/perl/TestLib.pm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use strict;
1111
use warnings;
1212

1313
use Config;
14+
use Cwd;
1415
use Exporter 'import';
1516
use File::Basename;
1617
use File::Spec;
@@ -156,6 +157,33 @@ sub tempdir_short
156157
return File::Temp::tempdir(CLEANUP => 1);
157158
}
158159

160+
# Translate a Perl file name to a host file name. Currently, this is a no-op
161+
# except for the case of Perl=msys and host=mingw32. The subject need not
162+
# exist, but its parent directory must exist.
163+
sub perl2host
164+
{
165+
my ($subject) = @_;
166+
return $subject unless $Config{osname} eq 'msys';
167+
my $here = cwd;
168+
my $leaf;
169+
if (chdir $subject)
170+
{
171+
$leaf = '';
172+
}
173+
else
174+
{
175+
$leaf = '/' . basename $subject;
176+
my $parent = dirname $subject;
177+
chdir $parent or die "could not chdir \"$parent\": $!";
178+
}
179+
180+
# this odd way of calling 'pwd -W' is the only way that seems to work.
181+
my $dir = qx{sh -c "pwd -W"};
182+
chomp $dir;
183+
chdir $here;
184+
return $dir . $leaf;
185+
}
186+
159187
sub system_log
160188
{
161189
print("# Running: " . join(" ", @_) . "\n");

0 commit comments

Comments
 (0)