When a log contains a known failure, link it to the corresponding failure details page(s).
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48912 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/JobDetails.pl | 54 +++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-)
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index 7860a4c9d..efdd4d9b0 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -237,6 +237,7 @@ our @ISA = qw(ObjectModel::CGI::CollectionPage); use URI::Escape;
use WineTestBot::Config; +use WineTestBot::Failures; use WineTestBot::Jobs; use WineTestBot::Log; # For Elapsed() use WineTestBot::LogUtils; @@ -260,6 +261,7 @@ sub _initialize($$$) { $self->SetRefreshInterval(30); } + $self->{Failures} = CreateFailures(); }
sub GetJob($) @@ -378,6 +380,30 @@ sub GenerateMoreInfoLink($$$$;$$) print "<div class='TaskMoreInfoLink'>$Html</div>\n"; }
+sub GetFailureLink($$;$) +{ + my ($self, $Id, $Str) = @_; + + my $Failure = $self->{Failures}->GetItem($Id); + $Str ||= $Failure ? $Failure->BugId : "F$Id"; + my $Desc = $Failure->BugDescription if ($Failure); + $Desc = ": ". $self->escapeHTML($Desc) if ($Desc); + return "<a href='FailureDetails.pl?Key=$Id' title='Failure $Id$Desc'>$Str</a>"; +} + +sub GetFailureLinks($$) +{ + my ($self, $FailureIds) = @_; + + return join(" ", map { $self->GetFailureLink($_) } + sort { + my $FA = $self->{Failures}->GetItem($a); + my $FB = $self->{Failures}->GetItem($b); + return ($FA ? $FA->BugId : 0) <=> ($FB ? $FB->BugId : 0) + || $a <=> $b; + } @$FailureIds); +} + sub GenerateFullLog($$$$) { my ($self, $Dir, $LogName, $HideLog) = @_; @@ -400,14 +426,18 @@ sub GenerateFullLog($$$$) print "<pre class='log-note'>Some WineTest results could not be used to detect new errors: $LogInfo->{BadRef}</pre>\n"; }
- my %ErrCategory; + my (%ErrCategory, %ErrFailures); foreach my $GroupName (@{$LogInfo->{ErrGroupNames}}) { my $Group = $LogInfo->{ErrGroups}->{$GroupName}; for my $ErrIndex (0..$#{$Group->{Errors}}) { my $LineNo = $Group->{LineNos}->[$ErrIndex]; - $ErrCategory{$LineNo} = $Group->{IsNew}->[$ErrIndex] ? "fullnew" : "error"; + if ($LineNo) + { + $ErrCategory{$LineNo} = $Group->{IsNew}->[$ErrIndex] ? "fullnew" : "error"; + $ErrFailures{$LineNo} = $Group->{Failures}->{$ErrIndex}; + } } }
@@ -435,6 +465,11 @@ sub GenerateFullLog($$$$) { $Html =~ s~^(.*\S)\s*\r?$~<span class='log-$Category'>$1</span>~; } + if ($ErrFailures{$LineNo}) + { + print "[", $self->GetFailureLinks($ErrFailures{$LineNo}), "] "; + $Html = $self->GetFailureLink($ErrFailures{$LineNo}->[0], $Html); + } print "$Html\n"; } close($LogFile); @@ -464,6 +499,11 @@ sub GenerateFullLog($$$$) my $Line = $Group->{Errors}->[$ErrIndex]; my $Category = $Group->{IsNew}->[$ErrIndex] ? "new" : "error"; my $Html = $self->escapeHTML($Line); + if ($Group->{Failures}->{$ErrIndex}) + { + print "[", $self->GetFailureLinks($Group->{Failures}->{$ErrIndex}), "] "; + $Html = $self->GetFailureLink($Group->{Failures}->{$ErrIndex}->[0], $Html); + } print "<span class='log-$Category'>$Html</span>\n"; } } @@ -629,14 +669,18 @@ EOF my $Group = $LogInfo->{ErrGroups}->{$GroupName}; foreach my $Line (@{$Group->{Errors}}) { + my $Html = $self->escapeHTML($Line); if ($Group->{IsNew}->[$ErrIndex]) { - print "<span class='log-new'>", $self->escapeHTML($Line), "</span>\n"; + $Html = "<span class='log-new'>$Html</span>"; } - else + my $FailureIds = $Group->{Failures}->{$ErrIndex}; + if ($FailureIds) { - print $self->escapeHTML($Line), "\n"; + print "[", $self->GetFailureLinks($FailureIds), "] "; + $Html = $self->GetFailureLink($FailureIds->[0], $Html); } + print "$Html\n"; $ErrIndex++; } print "</code></pre>\n";