Module: tools Branch: master Commit: b6f41769733d351c0d8e8bbd2f3c1b79bb55023a URL: https://source.winehq.org/git/tools.git/?a=commit;h=b6f41769733d351c0d8e8bbd...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Jan 25 14:52:37 2021 +0100
testbot/TestWTBS: Allow checking the web patches status.
Checks the Failed / OK status on Wine's 'Patch status' page.
For instance: ----- TestWTBS ----- p webpatch.Status Failed ----- TestWTBS -----
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/tests/TestWTBS | 100 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 3 deletions(-)
diff --git a/testbot/tests/TestWTBS b/testbot/tests/TestWTBS index 5686428..0980081 100755 --- a/testbot/tests/TestWTBS +++ b/testbot/tests/TestWTBS @@ -202,7 +202,7 @@ sub DumpTestInfo($) { my ($TestInfo) = @_;
- foreach my $Category ("patch", "job", "tasks", "tests", "win", + foreach my $Category ("webpatch", "patch", "job", "tasks", "tests", "win", "build", "win32", "win64", "wine") { WineTestBot::LogUtils::_WriteLogErrorsToFh(*STDERR, $TestInfo->{$Category}); @@ -225,6 +225,12 @@ sub CheckValue($) return (defined $Value and $Value ne "ignore"); }
+sub SkipCheck($) +{ + my ($Value) = @_; + return (defined $Value and $Value eq "ignore"); +} + sub LoadTestInfo($) { my ($FileName) = @_; @@ -280,7 +286,7 @@ sub LoadTestInfo($)
# Split up the information to jobs, tasks, etc. my $TestInfo = { - patch => {}, job => {}, + webpatch => {}, patch => {}, job => {}, tasks => {}, tests => {}, win => {}, build => {}, win32 => {}, win64 => {}, wine => {}, }; @@ -288,7 +294,7 @@ sub LoadTestInfo($) foreach my $Entry (keys %{$RawInfo}) { my $Field = lcfirst($Entry); - if ($Field =~ s/^(patch|job|tasks|tests|win|build|win32|win64|wine).//) + if ($Field =~ s/^(webpatch|patch|job|tasks|tests|win|build|win32|win64|wine).//) { my $TaskType = $1; $TestInfo->{$TaskType}->{$Field} = $RawInfo->{$Entry}; @@ -374,6 +380,20 @@ sub LoadTestInfo($) } }
+ # Automatically check webpatch.Status in simple cases + if (!defined $TestInfo->{patch}->{Disposition} and + CheckValue($TestInfo->{job}->{Status}) and + !SkipCheck($TestInfo->{win32}->{TestFailures}) and + !SkipCheck($TestInfo->{win64}->{TestFailures}) and + !SkipCheck($TestInfo->{wine}->{TestFailures})) + { + my $Status = ($TestInfo->{job}->{Status} ne 'completed' or + $TestInfo->{win32}->{TestFailures} or + $TestInfo->{win64}->{TestFailures} or + $TestInfo->{wine}->{TestFailures}) ? "Failed" : "OK"; + SetDefault($TestInfo, "webpatch", "Status", $Status); + } + return $TestInfo; }
@@ -803,6 +823,78 @@ sub CheckJobs()
=pod
+=item <webpatch.Status> + +Checks the webpatch's status. +This is the 'Failed' or 'OK' status on the Wine 'Patch status' page (outside +the TestBot). +If patch.Disposition is not set the default is to expect the status to be +'Failed' if job.Status is not 'completed' or any of the tests has a non-zero +TestFailures field; and 'OK' otherwise. + +For instance: +p webpatch.Status Failed + +=cut + +sub CheckWebPatch($$$) +{ + my ($Patch, $Job, $TestInfo) = @_; + + # Only patches submitted through WinePatchesWebSubmit.pl get a WebPatchId. + return if (!$Patch->WebPatchId or !-d "$DataDir/webpatches"); + + my $WebFileName = "$DataDir/webpatches/". $Patch->WebPatchId; + ok(-f $WebFileName, "Check presence of the ". $Patch->WebPatchId ." webpatch"); + + my $WebResultFile = "$WebFileName.testbot"; + if (!$Job or $Job->Status !~ /^(completed|badpatch|badbuild|boterror)$/) + { + ok(!-f $WebResultFile, "Check absence of the ". $Patch->WebPatchId ." TestBot result file"); + return; + } + + ok(-f $WebResultFile, "Check presence of the ". $Patch->WebPatchId ." TestBot result file for job ". $Job->Id); + + if (open(my $ResultFh, "<", $WebResultFile)) + { + my ($HasStatus, $HasJobId, $HasURL); + while (my $Line = <$ResultFh>) + { + if ($Line =~ /^Status: (\w+)$/) + { + my $WebStatus = $1; + if (CheckValue($TestInfo->{webpatch}->{Status})) + { + is($WebStatus, $TestInfo->{webpatch}->{Status}, "Check the ". $Patch->WebPatchId ." web patch status (job ". $Job->Id .")"); + } + $HasStatus = 1; + } + elsif ($Line =~ /^Job-ID: (\d+)$/) + { + is($1, $Job->Id, "Check the ". $Patch->WebPatchId ." job id"); + $HasJobId = 1; + } + elsif ($Line =~ /^URL: (.+)$/) + { + my $JobId = $Job->Id; + ok($1 =~ m~\Q/$WebHostName\E/JobDetails.pl?Key=$JobId$~, + "Check the ". $Patch->WebPatchId ." URL"); + $HasURL = 1; + } + # Ignore the rest of the file + last if ($HasStatus and $HasJobId and $HasURL); + } + close($ResultFh); + } + else + { + fail("Could not open $WebResultFile for reading: $!"); + } +} + +=pod + =item <patch.Disposition>
Checks the patch's disposition. @@ -860,6 +952,8 @@ sub CheckPatch($$$) { fail("Patch ". $Patch->Id ."(". $Patch->Subject .") should have an associated job but Disposition is: ". $Patch->Disposition); } + + CheckWebPatch($Patch, $Job, $TestInfo); }
sub CheckPatches()