Skip to content

Commit a1f2799

Browse files
authored
Merge pull request #6855 from rbmarliere/ktap_unparsed_default
parser: ktap: Show full output by default if no line was parsed
2 parents 7222384 + 7b3f46b commit a1f2799

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

lib/OpenQA/Parser/Format/KTAP.pm

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ sub _parse_subtest ($self, $result) {
4848
$self->test or return;
4949

5050
my $line = $result->as_string;
51-
return unless $line =~ /^#\s*(?<status>ok|not ok)\s+(?<index>\d+)\s+(?<name>[^#]*)/;
51+
unless ($line =~ /^#\s*(?<status>ok|not ok)\s+(?<index>\d+)\s+(?<name>[^#]*)/) {
52+
push @{$steps->{unparsed_lines}}, $line;
53+
return;
54+
}
55+
$steps->{parsed_lines_count}++;
5256
return if $line =~ /#\s*SKIP\b/i;
5357
my ($status, $index, $subtest_name) = @+{qw(status index name)};
5458

@@ -92,6 +96,22 @@ sub _testgroup_finalize ($self, $result) {
9296

9397
$steps->{name} = $self->test->{name};
9498
$steps->{test} = $self->test;
99+
100+
# If there are no parsed lines, default to simply show the whole log.
101+
# This is better than not showing anything, impeding the user to see
102+
# the buttons of adding product or test bugs and requiring them to
103+
# search and open individual log assets.
104+
if (!$steps->{parsed_lines_count}) {
105+
my $filename = "KTAP-@{[$steps->{name}]}.txt";
106+
push @{$steps->{details}},
107+
{
108+
text => $filename,
109+
title => $steps->{name},
110+
result => 'ok',
111+
};
112+
$self->_add_output({file => $filename, content => join("\n", @{$steps->{unparsed_lines}})});
113+
}
114+
95115
$self->generated_tests_results->add(OpenQA::Parser::Result::OpenQA->new($steps));
96116

97117
$self->test(undef);
@@ -106,11 +126,11 @@ sub parse ($self, $KTAP) {
106126
while (my $result = $parser->next) {
107127
next if $result->type eq 'version' || $result->type eq 'plan';
108128

109-
if ($result->type eq 'comment' && $result->as_string =~ /^#\s*selftests:\s+/) {
110-
$self->_testgroup_init($result->as_string);
111-
next;
112-
}
113-
if ($result->type eq 'comment' && $result->as_string =~ /^#\s*(ok|not ok)\s+\d+\s+/) {
129+
if ($result->type eq 'comment') {
130+
if ($result->as_string =~ /^#\s*selftests:\s+/) {
131+
$self->_testgroup_init($result->as_string);
132+
next;
133+
}
114134
$self->_parse_subtest($result);
115135
next;
116136
}

0 commit comments

Comments
 (0)