mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Tighten up Windows CRLF conversion in our TAP test scripts.
The previous approach was to search-and-destroy all \r occurrences no matter what. That seems more likely to hide bugs than anything else; indeed it seems to be hiding one now. Fix things so that we only transform \r\n to \n. Side effects: must do this before, not after, chomp'ing if we're going to chomp, else we'd fail to clean up a trailing \r\n. Also, remove safe_psql's redundant repetition of what psql already did; else it might reduce \r\r\n to \n, which is exactly the scenario I'm hoping to expose. Perhaps this should be back-patched, but for now I'm content to see what happens in HEAD. Discussion: https://postgr.es/m/412ae8da-76bb-640f-039a-f3513499e53d@gmx.net
This commit is contained in:
parent
2b7dbc0db6
commit
91bdf499b3
@ -112,7 +112,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");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1324,7 +1324,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1515,14 +1514,14 @@ sub psql
|
|||||||
|
|
||||||
if (defined $$stdout)
|
if (defined $$stdout)
|
||||||
{
|
{
|
||||||
|
$$stdout =~ s/\r\n/\n/g if $TestLib::windows_os;
|
||||||
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 $TestLib::windows_os;
|
||||||
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
|
||||||
@ -1652,8 +1651,8 @@ sub poll_query_until
|
|||||||
{
|
{
|
||||||
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 $TestLib::windows_os;
|
||||||
chomp($stdout);
|
chomp($stdout);
|
||||||
$stdout =~ s/\r//g if $TestLib::windows_os;
|
|
||||||
|
|
||||||
if ($stdout eq $expected)
|
if ($stdout eq $expected)
|
||||||
{
|
{
|
||||||
@ -1668,8 +1667,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 $TestLib::windows_os;
|
||||||
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:
|
||||||
@ -2113,8 +2112,8 @@ sub pg_recvlogical_upto
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$stdout =~ s/\r//g if $TestLib::windows_os;
|
$stdout =~ s/\r\n/\n/g if $TestLib::windows_os;
|
||||||
$stderr =~ s/\r//g if $TestLib::windows_os;
|
$stderr =~ s/\r\n/\n/g if $TestLib::windows_os;
|
||||||
|
|
||||||
if (wantarray)
|
if (wantarray)
|
||||||
{
|
{
|
||||||
|
@ -430,7 +430,7 @@ sub slurp_file
|
|||||||
CloseHandle($fHandle)
|
CloseHandle($fHandle)
|
||||||
or die "could not close \"$filename\": $^E\n";
|
or die "could not close \"$filename\": $^E\n";
|
||||||
}
|
}
|
||||||
$contents =~ s/\r//g if $Config{osname} eq 'msys';
|
$contents =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user