1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-03 22:24:49 +03:00

Tighten up Windows CRLF conversion in our TAP test scripts.

Back-patch commits 91bdf499b and ffb4cee43, so that all branches
agree on when and how to do Windows CRLF conversion.

This should close the referenced thread.  Thanks to Andrew Dunstan
for discussion/review.

Discussion: https://postgr.es/m/412ae8da-76bb-640f-039a-f3513499e53d@gmx.net
This commit is contained in:
Tom Lane 2020-07-09 17:38:52 -04:00
parent 2d7738a83c
commit ce9d053423
3 changed files with 10 additions and 7 deletions

View File

@ -107,7 +107,7 @@ sub check_query
} }
else 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"); is($stdout, $expected_stdout, "$test_name: query result matches");
} }
} }

View File

@ -1122,7 +1122,6 @@ sub safe_psql
print "\n#### End standard error\n"; print "\n#### End standard error\n";
} }
$stdout =~ s/\r//g if $TestLib::windows_os;
return $stdout; return $stdout;
} }
@ -1297,16 +1296,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) if (defined $$stdout)
{ {
$$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
chomp $$stdout; chomp $$stdout;
$$stdout =~ s/\r//g if $TestLib::windows_os;
} }
if (defined $$stderr) if (defined $$stderr)
{ {
$$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
chomp $$stderr; chomp $$stderr;
$$stderr =~ s/\r//g if $TestLib::windows_os;
} }
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR # See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
@ -1364,8 +1367,8 @@ sub poll_query_until
[ 'psql', '-XAt', '-c', $query, '-d', $self->connstr($dbname) ]; [ 'psql', '-XAt', '-c', $query, '-d', $self->connstr($dbname) ];
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr; my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
chomp($stdout); chomp($stdout);
$stdout =~ s/\r//g if $TestLib::windows_os;
if ($stdout eq "t") if ($stdout eq "t")
{ {
return 1; return 1;
@ -1378,8 +1381,8 @@ sub poll_query_until
# The query result didn't change in 180 seconds. Give up. Print the # The query result didn't change in 180 seconds. Give up. Print the
# output from the last attempt, hopefully that's useful for debugging. # output from the last attempt, hopefully that's useful for debugging.
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
chomp($stderr); chomp($stderr);
$stderr =~ s/\r//g if $TestLib::windows_os;
diag qq(poll_query_until timed out executing this query: diag qq(poll_query_until timed out executing this query:
$query $query
expecting this output: expecting this output:

View File

@ -216,7 +216,7 @@ sub slurp_file
or die "could not read \"$filename\": $!"; or die "could not read \"$filename\": $!";
my $contents = <$in>; my $contents = <$in>;
close $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; return $contents;
} }