diff --git a/src/bin/pg_rewind/t/RewindTest.pm b/src/bin/pg_rewind/t/RewindTest.pm index 8469c9c2d3..506e103f79 100644 --- a/src/bin/pg_rewind/t/RewindTest.pm +++ b/src/bin/pg_rewind/t/RewindTest.pm @@ -113,7 +113,7 @@ sub check_query } else { - $stdout =~ s/\r//g if $Config{osname} eq 'msys'; + $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys'; is($stdout, $expected_stdout, "$test_name: query result matches"); } return; diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index bbb31d3a0d..c3939edc53 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -1247,7 +1247,6 @@ sub safe_psql print "\n#### End standard error\n"; } - $stdout =~ s/\r//g if $TestLib::windows_os; return $stdout; } @@ -1423,16 +1422,20 @@ 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 $Config{osname} eq 'msys'; chomp $$stdout; - $$stdout =~ s/\r//g if $TestLib::windows_os; } if (defined $$stderr) { + $$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys'; chomp $$stderr; - $$stderr =~ s/\r//g if $TestLib::windows_os; } # See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR @@ -1495,8 +1498,8 @@ sub poll_query_until { my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr; + $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys'; chomp($stdout); - $stdout =~ s/\r//g if $TestLib::windows_os; if ($stdout eq $expected) { @@ -1511,8 +1514,8 @@ 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 $Config{osname} eq 'msys'; chomp($stderr); - $stderr =~ s/\r//g if $TestLib::windows_os; diag qq(poll_query_until timed out executing this query: $query expecting this output: @@ -1946,8 +1949,8 @@ sub pg_recvlogical_upto } }; - $stdout =~ s/\r//g if $TestLib::windows_os; - $stderr =~ s/\r//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) { diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 9981265766..34841ff965 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -254,7 +254,7 @@ sub slurp_file or die "could not read \"$filename\": $!"; my $contents = <$in>; close $in; - $contents =~ s/\r//g if $Config{osname} eq 'msys'; + $contents =~ s/\r\n/\n/g if $Config{osname} eq 'msys'; return $contents; }