From: Francois Gouget Subject: [08/25] testbot/LogUtils: Tweak ParseTaskLog() to reduce the indentation level. Message-Id: <0927e8b2984a0abd6ffa1b4ecfe064b6b534c4bb.1579000229.git.fgouget@codeweavers.com> Date: Tue, 14 Jan 2020 16:41:42 +0100 (CET) In-Reply-To: References: It also better matches the ParseWineTestReport() structure. --- testbot/lib/WineTestBot/LogUtils.pm | 60 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index dd8228e69..4d1ddda8c 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -92,39 +92,41 @@ sub ParseTaskLog($) { my ($FileName) = @_; - if (open(my $LogFile, "<", $FileName)) + my $LogFile; + if (!open($LogFile, "<", $FileName)) { - my $LogInfo = {Type => "build"}; - foreach my $Line (<$LogFile>) + return {NoLog => "Unable to open the task log for reading: $!"}; + } + + my $LogInfo = {Type => "build"}; + foreach my $Line (<$LogFile>) + { + chomp $Line; + if ($Line eq "Task: tests") { - chomp $Line; - if ($Line eq "Task: tests") - { - $LogInfo->{Type} = "tests"; - } - elsif ($Line eq "Task: ok") - { - $LogInfo->{Task} ||= "ok"; - } - elsif ($Line eq "Task: Patch failed to apply") - { - $LogInfo->{Task} = "badpatch"; - last; # Should be the last and most specific message - } - elsif ($Line =~ /^Task: Updated ([a-zA-Z0-9.]+)$/) - { - $LogInfo->{$1} = "updated"; - } - elsif ($Line =~ /^Task: / or _IsPerlError($Line)) - { - $LogInfo->{Task} = "failed"; - } + $LogInfo->{Type} = "tests"; + } + elsif ($Line eq "Task: ok") + { + $LogInfo->{Task} ||= "ok"; + } + elsif ($Line eq "Task: Patch failed to apply") + { + $LogInfo->{Task} = "badpatch"; + last; # Should be the last and most specific message + } + elsif ($Line =~ /^Task: Updated ([a-zA-Z0-9.]+)$/) + { + $LogInfo->{$1} = "updated"; + } + elsif ($Line =~ /^Task: / or _IsPerlError($Line)) + { + $LogInfo->{Task} = "failed"; } - close($LogFile); - $LogInfo->{Task} ||= "missing"; - return $LogInfo; } - return {NoLog => "Unable to open the task log for reading: $!"}; + close($LogFile); + $LogInfo->{Task} ||= "missing"; + return $LogInfo; } -- 2.20.1