1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add stderr to unit test error messages.

Messages on stderr were being lost due to the error suppression used to customize the error message.

Also update the formatting to be more informative and concise.
This commit is contained in:
David Steele 2021-01-24 08:23:59 -05:00
parent f95850c546
commit 5cb9f166ec
2 changed files with 25 additions and 3 deletions

View File

@ -233,7 +233,9 @@ sub endRetry
if ($self->{bSuppressError})
{
&log(DEBUG, "suppressed error was ${iExitStatus}");
$self->{strErrorLog} = '';
# Make a copy of the suppressed error log in case it is needed
$self->{strSuppressedErrorLog} = $self->{strErrorLog};
}
else
{

View File

@ -657,9 +657,29 @@ sub end
# Output error
if ($iExitStatus != 0)
{
# Get stdout
my $strOutput = trim($oExecDone->{strOutLog}) ? "STDOUT:\n" . trim($oExecDone->{strOutLog}) : '';
# Get stderr
if (trim($oExecDone->{strSuppressedErrorLog}) ne '')
{
if ($strOutput ne '')
{
$strOutput .= "\n";
}
$strOutput .= "STDERR:\n" . trim($oExecDone->{strSuppressedErrorLog});
}
# If no stdout or stderr output something rather than a blank line
if ($strOutput eq '')
{
$strOutput = 'NO OUTPUT ON STDOUT OR STDERR';
}
&log(ERROR, "${strTestDone} (err${iExitStatus}" . ($self->{bLogTimestamp} ? "-${fTestElapsedTime}s)" : '') .
(defined($oExecDone->{strOutLog}) && !$self->{bShowOutputAsync} ?
":\n\n" . trim($oExecDone->{strOutLog}) . "\n" : ''), undef, undef, 4);
(defined($oExecDone->{strOutLog}) && !$self->{bShowOutputAsync} ? ":\n\n${strOutput}\n" : ''), undef, undef, 4);
$bFail = true;
}
# Output success