[tools] testbot/TestWTBS: Convert the job ranges into patch ranges.
Francois Gouget
fgouget at codeweavers.com
Tue Feb 2 21:33:16 CST 2021
Check all patches that have a job that falls in the job ranges, or are
in the set of no-job patches surrounding those.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This ensures any test that results in a no-job patch disposition (e.g.
"Part is not a Wine patch") will be checked, even if they are at the
start or end of the job list.
testbot/tests/TestWTBS | 75 +++++++++++++++++++++++++++++-------------
1 file changed, 53 insertions(+), 22 deletions(-)
diff --git a/testbot/tests/TestWTBS b/testbot/tests/TestWTBS
index f6ca54e84..87b53fea5 100755
--- a/testbot/tests/TestWTBS
+++ b/testbot/tests/TestWTBS
@@ -131,7 +131,7 @@ while (@ARGV)
}
}
-my @JobRanges;
+my $JobRanges = [];
if (!defined $Usage)
{
if (defined $OptJobs)
@@ -140,11 +140,11 @@ if (!defined $Usage)
{
if ($Range =~ /^([0-9]+)$/)
{
- push @JobRanges, [$1, $1];
+ push @$JobRanges, [$1, $1];
}
elsif ($Range =~ /^([0-9]*)\.\.([0-9]*)/)
{
- push @JobRanges, [$1 || 0, $2 || 0];
+ push @$JobRanges, [$1 || 0, $2 || 0];
}
else
{
@@ -983,15 +983,16 @@ sub CheckJob($$)
}
}
-sub IsJobInRange($)
+sub IsInRange($$)
{
- my ($Job) = @_;
+ my ($Ranges, $Id) = @_;
- return 1 if (!@JobRanges);
- foreach my $Range (@JobRanges)
+ return 0 if (!$Id);
+ return 1 if (!$Ranges or !@$Ranges);
+ foreach my $Range (@$Ranges)
{
- return 1 if (($Range->[0] == 0 or $Range->[0] <= $Job->Id) and
- ($Range->[1] == 0 or $Job->Id <= $Range->[1]));
+ return 1 if (($Range->[0] == 0 or $Range->[0] <= $Id) and
+ ($Range->[1] == 0 or $Id <= $Range->[1]));
}
return 0;
}
@@ -1040,7 +1041,7 @@ but not parts 3 and 4.
sub CheckJobTree($;$)
{
my ($Job, $TestInfo) = @_;
- return if (!IsJobInRange($Job));
+ return if (!IsInRange($JobRanges, $Job->Id));
my $JobId = $Job->Id; # Simplify use in strings
return if ($CheckedJobs{$JobId});
@@ -1267,28 +1268,20 @@ sub CheckPatch($$$)
{
$Job = $Jobs->GetItem($1);
}
- # The job range restriction extends to their associated patches...
- return if ($Job and !IsJobInRange($Job));
- # ..and to patches with no job
- return if (!$Job and @JobRanges);
my $PatchInfo = $TestInfo->{patch};
if (CheckValue($PatchInfo->{Disposition}))
{
is($Patch->Disposition, $PatchInfo->{Disposition}, "Check Disposition for patch ". $Patch->Id .": ". $Patch->Subject);
}
- elsif ($Patch->Disposition =~ /^Submitted job (.*)$/)
+ elsif ($Job)
{
- isnt($Job, undef, "Check job $1 for patch ". $Patch->Id .": ". $Patch->Subject);
- if (!$Job or $Job->Status eq "canceled")
- {
- ; # Nothing to check
- }
- elsif ($Job->Status =~ /^(?:queued|running)$/)
+ isnt($Job, undef, "Check job ". $Job->Id ." for patch ". $Patch->Id .": ". $Patch->Subject);
+ if ($Job->Status =~ /^(?:queued|running)$/)
{
print "...skipping job ". $Job->Id ." because it is not complete yet (". $Job->Status .")\n";
}
- else
+ elsif ($Job->Status ne "canceled")
{
# Provide defaults for the job checks
my $Remarks = $Patch->Subject;
@@ -1310,8 +1303,46 @@ sub CheckPatches()
{
my $Jobs = CreateJobs();
my $Patches = CreatePatches();
+
+ my $PatchRanges = [];
+ if (@$JobRanges)
+ {
+ # Convert the job ranges into a list of patch ranges so that these patches:
+ # 1. either have a job in the allowed job ranges,
+ # 2. or have no job but are contiguous to a patch satisfying 1 or 2.
+ my ($First, $Last, $AddRange);
+ foreach my $Patch (sort { $a->Id <=> $b->Id } @{$Patches->GetItems()})
+ {
+ if ($Patch->Disposition =~ /^Submitted job (\d+)$/)
+ {
+ my $Job = $Jobs->GetItem($1);
+ if ($Job and IsInRange($JobRanges, $Job->Id))
+ {
+ $AddRange = 1;
+ }
+ elsif ($AddRange)
+ {
+ push @$PatchRanges, [$First, $Last];
+ $First = $Last = $AddRange = undef;
+ next;
+ }
+ else
+ {
+ $First = $Last = $AddRange = undef;
+ next;
+ }
+ }
+
+ $First = $Patch->Id if (!$First);
+ $Last = $Patch->Id;
+ }
+ push @$PatchRanges, [$First, $Last] if ($AddRange);
+ }
+
foreach my $Patch (sort { $b->Id <=> $a->Id } @{$Patches->GetItems()})
{
+ next if (!IsInRange($PatchRanges, $Patch->Id));
+
my $PatchFileName = "$DataDir/patches/". $Patch->Id;
if (-f $PatchFileName)
{
--
2.20.1
More information about the wine-devel
mailing list