Further tighten Windows CRLF conversion in our TAP test scripts.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jul 2020 15:37:21 +0000 (11:37 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jul 2020 15:37:21 +0000 (11:37 -0400)
Buildfarm results now imply that Perl's IPC::Run does CRLF conversion
for us if we're using native Perl, but not when using MSys Perl.
Restrict the conversions done by PostgresNode.pm to act only in the
latter case.  (Similar conversions done in TestLib.pm and RewindTest.pm
were already handled this way.)

Discussion: https://postgr.es/m/412ae8da-76bb-640f-039a-f3513499e53d@gmx.net

src/test/perl/PostgresNode.pm

index 0914fdaa463fa54c602681ba9812eba49dff9c56..8c1b77376fb081a7f365f0f41a76ce7d9587b104 100644 (file)
@@ -1512,15 +1512,19 @@ sub psql
        }
    };
 
+   # Note: on Windows, IPC::Run seems to convert \r\n to \n in program output
+   # if we're using native Perl, but not if we're using MSys Perl.  So do it
+   # by hand in the latter case, here and elsewhere.
+
    if (defined $$stdout)
    {
-       $$stdout =~ s/\r\n/\n/g if $TestLib::windows_os;
+       $$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
        chomp $$stdout;
    }
 
    if (defined $$stderr)
    {
-       $$stderr =~ s/\r\n/\n/g if $TestLib::windows_os;
+       $$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
        chomp $$stderr;
    }
 
@@ -1651,7 +1655,7 @@ sub poll_query_until
    {
        my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
 
-       $stdout =~ s/\r\n/\n/g if $TestLib::windows_os;
+       $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
        chomp($stdout);
 
        if ($stdout eq $expected)
@@ -1667,7 +1671,7 @@ sub poll_query_until
 
    # The query result didn't change in 180 seconds. Give up. Print the
    # output from the last attempt, hopefully that's useful for debugging.
-   $stderr =~ s/\r\n/\n/g if $TestLib::windows_os;
+   $stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
    chomp($stderr);
    diag qq(poll_query_until timed out executing this query:
 $query
@@ -2112,8 +2116,8 @@ sub pg_recvlogical_upto
        }
    };
 
-   $stdout =~ s/\r\n/\n/g if $TestLib::windows_os;
-   $stderr =~ s/\r\n/\n/g if $TestLib::windows_os;
+   $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
+   $stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
 
    if (wantarray)
    {