summaryrefslogtreecommitdiff
path: root/src/test/perl
diff options
context:
space:
mode:
authorNoah Misch2019-06-22 03:34:23 +0000
committerNoah Misch2019-06-22 03:34:23 +0000
commit660a2b19038b2f6b9f6bcb2c3297a47d5e3557a8 (patch)
tree4060acaf5506a94056c3b085def18b61f9efbe5f /src/test/perl
parent25b93a2967a4ebfb90168ca087026cc697fc4b77 (diff)
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
Diffstat (limited to 'src/test/perl')
-rw-r--r--src/test/perl/PostgresNode.pm13
-rw-r--r--src/test/perl/TestLib.pm29
2 files changed, 21 insertions, 21 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 8d5ad6bc166..6019f37f912 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -107,15 +107,6 @@ our @EXPORT = qw(
our ($use_tcp, $test_localhost, $test_pghost, $last_host_assigned,
$last_port_assigned, @all_nodes, $died);
-# Windows path to virtual file system root
-
-our $vfs_path = '';
-if ($Config{osname} eq 'msys')
-{
- $vfs_path = `cd / && pwd -W`;
- chomp $vfs_path;
-}
-
INIT
{
@@ -945,7 +936,7 @@ primary_conninfo='$root_connstr'
sub enable_restoring
{
my ($self, $root_node) = @_;
- my $path = $vfs_path . $root_node->archive_dir;
+ my $path = TestLib::perl2host($root_node->archive_dir);
my $name = $self->name;
print "### Enabling WAL restore for node \"$name\"\n";
@@ -990,7 +981,7 @@ sub set_standby_mode
sub enable_archiving
{
my ($self) = @_;
- my $path = $vfs_path . $self->archive_dir;
+ my $path = TestLib::perl2host($self->archive_dir);
my $name = $self->name;
print "### Enabling WAL archiving for node \"$name\"\n";
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index f8eb7058a61..d2a9828dc62 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -166,22 +166,31 @@ sub tempdir_short
return File::Temp::tempdir(CLEANUP => 1);
}
-# Return the real directory for a virtual path directory under msys.
-# The directory must exist. If it's not an existing directory or we're
-# not under msys, return the input argument unchanged.
-sub real_dir
+# 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 $dir = "$_[0]";
- return $dir unless -d $dir;
- return $dir unless $Config{osname} eq 'msys';
+ my ($subject) = @_;
+ return $subject unless $Config{osname} eq 'msys';
my $here = cwd;
- chdir $dir;
+ 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.
- $dir = qx{sh -c "pwd -W"};
+ my $dir = qx{sh -c "pwd -W"};
chomp $dir;
chdir $here;
- return $dir;
+ return $dir . $leaf;
}
sub system_log