It's now possible to have the job details page show multiple screenshots and multiple logs. Once a screenshot / log is shown, the link can be clicked again to hide it. The code can also more easily be extended to handle more log files. The code inserting the links is simpler too.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/WineRunTask.pl | 2 +- testbot/web/JobDetails.pl | 156 +++++++++++++++++++++++-------------- 2 files changed, 97 insertions(+), 61 deletions(-)
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl index 3d8113fd9..c4ca578e2 100755 --- a/testbot/bin/WineRunTask.pl +++ b/testbot/bin/WineRunTask.pl @@ -448,7 +448,7 @@ elsif ($Step->Type eq "suite") if (defined($WebHostName)) { my $StepTask = 100 * $StepNo + $TaskNo; - $Script .= "-u "http://$WebHostName/JobDetails.pl?Key=$JobId&scrshot_$StepTask=1#k$StepT...""; + $Script .= "-u "http://$WebHostName/JobDetails.pl?Key=$JobId&s$StepTask=1#k$StepTask%5C""; } my $Info = $VM->Description ? $VM->Description : ""; if ($VM->Details) diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index 70d8b5983..f829407eb 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -228,12 +228,95 @@ sub GeneratePage($) $self->SUPER::GeneratePage(); }
+my %MILogLabels = ( + "log" => "task log", + "log.old" => "old logs", +); + +sub InitMoreInfo($) +{ + my ($self) = @_; + + my $More = $self->{More} = {}; + my $Keys = $self->SortKeys(undef, $self->{Collection}->GetKeys()); + foreach my $Key (@$Keys) + { + my $StepTask = $self->{Collection}->GetItem($Key); + $More->{$Key}->{Screenshot} = $self->GetParam("s$Key"); + + my $Value = $self->GetParam("f$Key"); + my $TaskDir = $StepTask->GetTaskDir(); + foreach my $Log ("log", "log.old") + { + if (!-f "$TaskDir/$Log" or -z "$TaskDir/$Log") + { + my $Err = $Log; + next if ($Err !~ s/^log/err/ or !-f "$TaskDir/$Err" or -z "$TaskDir/$Err"); + } + push @{$More->{$Key}->{Logs}}, $Log; + + $More->{$Key}->{Full} = $Log if (uri_escape($Log) eq $Value); + } + $More->{$Key}->{Full} ||= ""; + } +} + +sub GenerateMoreInfoLink($$$;$) +{ + my ($self, $LinkKey, $Label, $Set, $Value) = @_; + + my $Url = $ENV{"SCRIPT_NAME"} ."?Key=". uri_escape($self->{JobId}); + + my $Action = "Show"; + foreach my $Key (sort keys %{$self->{More}}) + { + my $MoreInfo = $self->{More}->{$Key}; + if ($Key eq $LinkKey and $Set eq "Screenshot") + { + if (!$MoreInfo->{Screenshot}) + { + $Url .= "&s$Key=1"; + } + else + { + $Action = "Hide"; + } + } + else + { + $Url .= "&s$Key=1" if ($MoreInfo->{Screenshot}); + } + + if ($Key eq $LinkKey and $Set eq "Full") + { + if ($MoreInfo->{Full} ne $Value) + { + $Url .= "&f$Key=". uri_escape($Value); + } + else + { + $Action = "Hide"; + } + } + else + { + $Url .= "&f$Key=". uri_escape($MoreInfo->{Full}) if ($MoreInfo->{Full}); + } + } + $Url .= "#k" . uri_escape($LinkKey); + + print "<div class='TaskMoreInfoLink'><a href='", + $self->CGI->escapeHTML($Url), "'>$Action $Label</a></div>\n"; +} + sub GenerateBody($) { my ($self) = @_;
$self->SUPER::GenerateBody();
+ $self->InitMoreInfo(); + print "<div class='Content'>\n"; my $Keys = $self->SortKeys(undef, $self->{Collection}->GetKeys()); foreach my $Key (@$Keys) @@ -249,18 +332,11 @@ sub GenerateBody($) $self->CGI->escapeHTML($VM->Details || "No details!"), "</details>\n";
- my $FullLogParamName = "log_$Key"; - my $FullLog = $self->GetParam($FullLogParamName); - $FullLog = "" if ($FullLog !~ /^[12]$/); - - my $ScreenshotParamName = "scrshot_$Key"; - my $Screenshot = $self->GetParam($ScreenshotParamName); - $Screenshot = "" if ($Screenshot ne "1"); - + my $MoreInfo = $self->{More}->{$Key}; print "<div class='TaskMoreInfoLinks'>\n"; if (-r "$TaskDir/screenshot.png") { - if ($Screenshot) + if ($MoreInfo->{Screenshot}) { my $URI = "/Screenshot.pl?JobKey=" . uri_escape($self->{JobId}) . "&StepKey=" . uri_escape($StepTask->StepNo) . @@ -268,59 +344,19 @@ sub GenerateBody($) print "<div class='Screenshot'><img src='" . $self->CGI->escapeHTML($URI) . "' alt='Screenshot' /></div>\n"; } - else - { - my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) . - "&$ScreenshotParamName=1"; - $URI .= "&$FullLogParamName=$FullLog"; - $URI .= "#k" . uri_escape($Key); - print "<div class='TaskMoreInfoLink'><a href='" . - $self->CGI->escapeHTML($URI) . - "'>Show final screenshot</a></div>"; - print "\n"; - } + $self->GenerateMoreInfoLink($Key, "final screenshot", "Screenshot"); }
- my $LogName = "$TaskDir/log"; - my $ErrName = "$TaskDir/err"; - if (-r $LogName and $FullLog != "1") - { - my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) . - "&$FullLogParamName=1"; - $URI .= "&$ScreenshotParamName=$Screenshot"; - $URI .= "#k" . uri_escape($Key); - print "<div class='TaskMoreInfoLink'><a href='" . - $self->CGI->escapeHTML($URI) . - "'>Show full log</a></div>\n"; - } - if ((-r $LogName or -r $ErrName) and $FullLog == "2") + foreach my $Log (@{$MoreInfo->{Logs}}) { - my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}); - $URI .= "&$ScreenshotParamName=$Screenshot"; - $URI .= "#k" . uri_escape($Key); - print "<div class='TaskMoreInfoLink'><a href='" . - $self->CGI->escapeHTML($URI) . - "'>Show latest log</a></div>\n"; - } - if ((-r "$LogName.old" or -r "$ErrName.old") and $FullLog != "2") - { - my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) . - "&$FullLogParamName=2"; - $URI .= "&$ScreenshotParamName=$Screenshot"; - $URI .= "#k" . uri_escape($Key); - print "<div class='TaskMoreInfoLink'><a href='" . - $self->CGI->escapeHTML($URI) . - "'>Show old logs</a></div>\n"; + $self->GenerateMoreInfoLink($Key, $MILogLabels{$Log}, "Full", $Log); } print "</div>\n";
- if ($FullLog eq "2") - { - $LogName .= ".old"; - $ErrName .= ".old"; - } + my $LogName = $MoreInfo->{Full} || $MoreInfo->{Logs}->[0] || "log"; + my $ErrName = $LogName eq "log.old" ? "err.old" : "err";
- if (open LOGFILE, "<$LogName") + if (open LOGFILE, "<", "$TaskDir/$LogName") { my $HasLogEntries = !1; my $First = 1; @@ -335,13 +371,13 @@ sub GenerateBody($) { $CurrentDll = $1; } - if ($FullLog || + if ($MoreInfo->{Full} || $Line =~ m/: Test (?:failed|succeeded inside todo block): / || $Line =~ m/Fatal: test '[^']+' does not exist/ || $Line =~ m/ done (258)/ || $Line =~ m/: unhandled exception [0-9a-fA-F]{8} at /) { - if ($PrintedDll ne $CurrentDll && ! $FullLog) + if ($PrintedDll ne $CurrentDll && !$MoreInfo->{Full}) { if ($First) { @@ -359,7 +395,7 @@ sub GenerateBody($) print "<pre><code>"; $First = !1; } - if (! $FullLog && $Line =~ m/^[^:]+:([^:]*)(?::[0-9a-f]+)? done (258)/) + if (!$MoreInfo->{Full} && $Line =~ m/^[^:]+:([^:]*)(?::[0-9a-f]+)? done (258)/) { my $Unit = $1 ne "" ? "$1: " : ""; print "${Unit}Timeout\n"; @@ -372,7 +408,7 @@ sub GenerateBody($) } close LOGFILE;
- if (open ERRFILE, "<$ErrName") + if (open ERRFILE, "<", "$TaskDir/$ErrName") { $CurrentDll = "*err*"; while (defined($Line = <ERRFILE>)) @@ -409,7 +445,7 @@ sub GenerateBody($) " failures found" : "Empty log"; } } - elsif (open ERRFILE, "<$ErrName") + elsif (open ERRFILE, "<", "$TaskDir/$ErrName") { my $HasErrEntries = !1; my $Line;
Show build errors in the log summary mode (like we already do for the test failures). Furthermore, when showing the full log, highlight the test failures and build errors so they are easier to spot. This uses the same color scheme as in the test.winehq.org website. Also make the boundaries between the test units more visible by highlighting their start line.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/web/JobDetails.pl | 61 +++++++++++++++++++++++++++++++++---- testbot/web/WineTestBot.css | 5 +++ 2 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl index f829407eb..3add52b4c 100644 --- a/testbot/web/JobDetails.pl +++ b/testbot/web/JobDetails.pl @@ -228,6 +228,58 @@ sub GeneratePage($) $self->SUPER::GeneratePage(); }
+sub GetHtmlLine($$$) +{ + my ($self, $FullLog, $Line) = @_; + + $Line = $self->escapeHTML($Line); + if ($Line =~ /: Test marked todo: /) + { + return (undef, $Line) if (!$FullLog); + my $Html = $Line; + $Html =~ s~^(.*\S)\s*\r?$~<span class='log-todo'>$1</span>~; + return ($Html, $Line); + } + if ($Line =~ /: Tests skipped: / or + $Line =~ /^\w+:\w+ skipped /) + { + return (undef, $Line) if (!$FullLog); + my $Html = $Line; + $Html =~ s~^(.*\S)\s*\r?$~<span class='log-skip'>$1</span>~; + return ($Html, $Line); + } + if ($Line =~ /: Test (?:failed|succeeded inside todo block): / or + $Line =~ /Fatal: test .* does not exist/ or + $Line =~ / done (258)/ or + $Line =~ /: unhandled exception [0-9a-fA-F]{8} at / or + $Line =~ /^Unhandled exception: / or + # Build errors + $Line =~ /: error: / or + $Line =~ /^error: patch failed:/ or + $Line =~ /^Makefile:[0-9]+: recipe for target .* failed$/ or + $Line =~ /^(?:Build|Reconfig|Task): (?!ok)/ or + # Typical perl errors + $Line =~ /^Use of uninitialized value/) + { + return ($Line, $Line) if (!$FullLog); + my $Html = $Line; + $Html =~ s~^(.*\S)\s*\r?$~<span class='log-error'>$1</span>~; + return ($Html, $Line); + } + if ($FullLog && + ($Line =~ /^+ \S/ or + $Line =~ /^\w+:\w+ start / or + # Build messages + $Line =~ /^(?:Build|Reconfig|Task): ok/)) + { + my $Html = $Line; + $Html =~ s~^(.*\S)\s*\r?$~<span class='log-info'>$1</span>~; + return ($Html, $Line); + } + + return (undef, $Line); +} + my %MILogLabels = ( "log" => "task log", "log.old" => "old logs", @@ -371,11 +423,8 @@ sub GenerateBody($) { $CurrentDll = $1; } - if ($MoreInfo->{Full} || - $Line =~ m/: Test (?:failed|succeeded inside todo block): / || - $Line =~ m/Fatal: test '[^']+' does not exist/ || - $Line =~ m/ done (258)/ || - $Line =~ m/: unhandled exception [0-9a-fA-F]{8} at /) + my ($Highlight, $Plain) = $self->GetHtmlLine($MoreInfo->{Full}, $Line); + if ($MoreInfo->{Full} || defined $Highlight) { if ($PrintedDll ne $CurrentDll && !$MoreInfo->{Full}) { @@ -402,7 +451,7 @@ sub GenerateBody($) } else { - print $self->escapeHTML($Line), "\n"; + print(($Highlight || $Plain), "\n"); } } } diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css index ebc622e34..28ac1b1c2 100644 --- a/testbot/web/WineTestBot.css +++ b/testbot/web/WineTestBot.css @@ -353,6 +353,11 @@ pre .boterror { color: #e55600; } .canceled { color: black; }
+.log-info { background-color: #d9ffcc; } +.log-skip { color: blue; } +.log-todo { color: #d08000; } +.log-error { color: red; } + a.title { color:inherit; text-decoration: none; }
th.Record { text-align: center; }