Make PG_TEST_USE_UNIX_SOCKETS work for tap tests on windows.
authorAndres Freund <andres@anarazel.de>
Mon, 13 Dec 2021 19:17:41 +0000 (11:17 -0800)
committerAndres Freund <andres@anarazel.de>
Mon, 13 Dec 2021 19:29:51 +0000 (11:29 -0800)
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 <andres@anarazel.de>
Reviewed-By: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/4da250a5-4222-1522-f14d-8a72bcf7e38e@enterprisedb.com

src/bin/pg_ctl/t/001_start_stop.pl
src/test/perl/PostgreSQL/Test/Cluster.pm

index f95352bf94fdea883bc7ac1d1b400c083e1fbeda..fdde4f0fb75dac6525c857e12140b7f9c90ae1c1 100644 (file)
@@ -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
index 9467a199c8f99cfa72e8fc9cff235f923f6d4059..c061e850fb098c6ccec8844666d593f1a942f949 100644 (file)
@@ -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';