Francois Gouget : testbot/WineSendLog: Use GetSortedItems() to sort the Steps/Tasks.
Module: tools Branch: master Commit: 8475a8ab57d626b10a82e443d0ba0e280b5d7345 URL: https://source.winehq.org/git/tools.git/?a=commit;h=8475a8ab57d626b10a82e443... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Mon Jun 13 17:20:44 2022 +0200 testbot/WineSendLog: Use GetSortedItems() to sort the Steps/Tasks. This avoids having to look up the object in every loop. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/bin/WineSendLog.pl | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/testbot/bin/WineSendLog.pl b/testbot/bin/WineSendLog.pl index 5affba6..8e2048e 100755 --- a/testbot/bin/WineSendLog.pl +++ b/testbot/bin/WineSendLog.pl @@ -183,7 +183,7 @@ sub SendLog($) } my $StepsTasks = CreateStepsTasks(undef, $Job); - my @SortedKeys = sort { $a <=> $b } @{$StepsTasks->GetKeys()}; + my $SortedStepsTasks = $StepsTasks->GetSortedItems(); my $JobURL = MakeOfficialURL("/JobDetails.pl?Key=". $Job->GetKey()); @@ -228,10 +228,8 @@ Content-Disposition: inline VM Status Failures Command EOF - foreach my $Key (@SortedKeys) + foreach my $StepTask (@$SortedStepsTasks) { - my $StepTask = $StepsTasks->GetItem($Key); - my $TestFailures = $StepTask->TestFailures; $TestFailures = "" if (!defined $TestFailures); my $Status = $StepTask->Status; @@ -248,19 +246,18 @@ EOF # Print the job summary my $JobErrors; - foreach my $Key (@SortedKeys) + foreach my $StepTask (@$SortedStepsTasks) { - my $StepTask = $StepsTasks->GetItem($Key); + my $Id = $StepTask->Id; my $TaskDir = $StepTask->GetTaskDir(); - my $LogNames = GetLogFileNames($TaskDir); - $JobErrors->{$Key}->{LogNames} = $LogNames; + $JobErrors->{$Id}->{LogNames} = $LogNames; foreach my $LogName (@$LogNames) { my $LogInfo = LoadLogErrors("$TaskDir/$LogName"); next if (!defined $LogInfo->{BadLog} and !$LogInfo->{ErrCount}); - $JobErrors->{$Key}->{HasErrors} = 1; - $JobErrors->{$Key}->{$LogName} = $LogInfo; + $JobErrors->{$Id}->{HasErrors} = 1; + $JobErrors->{$Id}->{$LogName} = $LogInfo; print $Sendmail "\n=== ", GetTitle($StepTask, $LogName), " ===\n"; print $Sendmail "$LogInfo->{BadLog}\n" if (defined $LogInfo->{BadLog}); @@ -275,12 +272,11 @@ EOF } # Print the log attachments - foreach my $Key (@SortedKeys) + foreach my $StepTask (@$SortedStepsTasks) { - my $StepTask = $StepsTasks->GetItem($Key); my $TaskDir = $StepTask->GetTaskDir(); - foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}}) + foreach my $LogName (@{$JobErrors->{$StepTask->Id}->{LogNames}}) { print $Sendmail <<"EOF"; @@ -325,19 +321,19 @@ EOF # However in practice this would only be an issue if the patch reintroduced # an error that just disappeared in the latest Wine which is highly unlikely. my @Messages; - foreach my $Key (@SortedKeys) + foreach my $StepTask (@$SortedStepsTasks) { - next if (!$JobErrors->{$Key}->{HasErrors}); - my $StepTask = $StepsTasks->GetItem($Key); + my $Id = $StepTask->Id; + next if (!$JobErrors->{$Id}->{HasErrors}); # Note: We could check $StepTask->Status for TestBot errors. However, # whether they are caused by the patch or not, they prevent the TestBot # from checking for new errors which justifies sending an email to the # mailing list so that the patch receives greater scrutiny. - foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}}) + foreach my $LogName (@{$JobErrors->{$Id}->{LogNames}}) { - my $LogInfo = $JobErrors->{$Key}->{$LogName}; + my $LogInfo = $JobErrors->{$Id}->{$LogName}; # Skip if there are no errors next if (!$LogInfo->{NewCount}); @@ -428,12 +424,10 @@ EOF DebugTee($Result, "Job-ID: ". $Job->Id ."\n"); DebugTee($Result, "URL: $JobURL\n"); - foreach my $Key (@SortedKeys) + foreach my $StepTask (@$SortedStepsTasks) { - my $StepTask = $StepsTasks->GetItem($Key); my $TaskDir = $StepTask->GetTaskDir(); - - foreach my $LogName (@{$JobErrors->{$Key}->{LogNames}}) + foreach my $LogName (@{$JobErrors->{$StepTask->Id}->{LogNames}}) { print $Result "=== ", GetTitle($StepTask, $LogName), " ===\n"; DumpLogAndErr($Result, "$TaskDir/$LogName");
participants (1)
-
Alexandre Julliard