Skip to content

Commit

Permalink
MDEV-24135: Print warnings in XML, save test retries in XML, save the…
Browse files Browse the repository at this point in the history
… combinations in XML, replace the special symbols in the XML comment
  • Loading branch information
DmitriyKarpovskiy1 authored and an3l committed Apr 12, 2021
1 parent 68e0def commit f776fa9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
30 changes: 19 additions & 11 deletions mysql-test/lib/mtr_report.pm
Original file line number Diff line number Diff line change
Expand Up @@ -497,23 +497,21 @@ sub mtr_report_stats ($$$$) {
$test_time = sprintf("%.3f", $test->{timer} / 1000);
$test->{'name'} =~ s/$current_suite\.//;

my $test_result;

# if a test case has to be retried it should have the result MTR_RES_FAILED in jUnit XML
if ($test->{'retries'} > 0) {
$test_result = "MTR_RES_FAILED";
my $combinations;
if (defined($test->{combinations})){
$combinations = join ',', sort @{$test->{combinations}};
} else {
$test_result = $test->{'result'};
$combinations = "";
}

$xml_report .= qq(\t\t<testcase assertions="" classname="$current_suite" name="$test->{'name'}" status="$test_result" time="$test_time");
$xml_report .= qq(\t\t<testcase assertions="" classname="$current_suite" name="$test->{'name'}" ).
qq(status="$test->{'result'}" time="$test_time" combinations="$combinations");

my $comment = $test->{'comment'};
$comment =~ s/[\"]//g;
my $comment= replace_special_symbols($test->{'comment'});

# if a test case has to be retried it should have the result MTR_RES_FAILED in jUnit XML
if ($test->{'result'} eq "MTR_RES_FAILED" || $test->{'retries'} > 0) {
if ($test->{'result'} eq "MTR_RES_FAILED") {
my $logcontents = $test->{'logfile-failed'} || $test->{'logfile'};
$logcontents= $logcontents.$test->{'warnings'}."\n";
# remove any double ] that would end the cdata
$logcontents =~ s/]]/\x{fffd}/g;
# replace wide characters that aren't allowed in XML 1.0
Expand Down Expand Up @@ -576,6 +574,16 @@ sub mtr_print_line () {
print '-' x 74 . "\n";
}

sub replace_special_symbols($) {
my $text= shift;
$text =~ s/&/&#38;/g;
$text =~ s/'/&#39;/g;
$text =~ s/"/&#34;/g;
$text =~ s/</&lt;/g;
$text =~ s/>/&gt;/g;
return $text;
}


sub mtr_print_thick_line {
my $char= shift || '=';
Expand Down
10 changes: 7 additions & 3 deletions mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,13 @@ ($$$)

rename $log_file_name, $log_file_name.".failed";
}
delete($result->{result});
$result->{retries}= $retries+1;
$result->write_test($sock, 'TESTCASE');
{
local @$result{'retries', 'result'};
delete $result->{result};
$result->{retries}= $retries+1;
$result->write_test($sock, 'TESTCASE');
}
push(@$completed, $result);
next;
}
}
Expand Down

0 comments on commit f776fa9

Please sign in to comment.