summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2021-12-13 19:17:41 +0000
committerAndres Freund2021-12-13 19:29:51 +0000
commit45f52709d86ceaaf282a440f6311c51fc526340b (patch)
treefdefba9bdee27fbe374926ee077b56334d956669
parentfa0e03c15a9f67671f0a6e0ec66d5e2ac7119c8a (diff)
Make PG_TEST_USE_UNIX_SOCKETS work for tap tests on windows.
We need to replace windows-style \ path separators with / when putting socket directories either in postgresql.conf or libpq connection strings, otherwise they are interpreted as escapes. Author: Andres Freund <[email protected]> Reviewed-By: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/bin/pg_ctl/t/001_start_stop.pl1
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl
index f95352bf94f..fdde4f0fb75 100644
--- a/src/bin/pg_ctl/t/001_start_stop.pl
+++ b/src/bin/pg_ctl/t/001_start_stop.pl
@@ -35,6 +35,7 @@ print $conf PostgreSQL::Test::Utils::slurp_file($ENV{TEMP_CONFIG})
if ($use_unix_sockets)
{
print $conf "listen_addresses = ''\n";
+ $tempdir_short =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;
print $conf "unix_socket_directories = '$tempdir_short'\n";
}
else
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 9467a199c8f..c061e850fb0 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -119,7 +119,18 @@ INIT
$use_tcp = !$PostgreSQL::Test::Utils::use_unix_sockets;
$test_localhost = "127.0.0.1";
$last_host_assigned = 1;
- $test_pghost = $use_tcp ? $test_localhost : PostgreSQL::Test::Utils::tempdir_short;
+ if ($use_tcp)
+ {
+ $test_pghost = $test_localhost;
+ }
+ else
+ {
+ # On windows, replace windows-style \ path separators with / when
+ # putting socket directories either in postgresql.conf or libpq
+ # connection strings, otherwise they are interpreted as escapes.
+ $test_pghost = PostgreSQL::Test::Utils::tempdir_short;
+ $test_pghost =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;
+ }
$ENV{PGHOST} = $test_pghost;
$ENV{PGDATABASE} = 'postgres';