Module: tools Branch: master Commit: a693b1d7751c5a40e7008137937c188b7e4e33f9 URL: https://source.winehq.org/git/tools.git/?a=commit;h=a693b1d7751c5a40e7008137...
Author: Francois Gouget fgouget@codeweavers.com Date: Wed Jan 20 13:56:57 2021 +0100
testbot/TestWTBS: Allow restricting the range of jobs to check.
This allows ignoring a previous test run that produced buggy results.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/tests/TestWTBS | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-)
diff --git a/testbot/tests/TestWTBS b/testbot/tests/TestWTBS index 786d369..6e1e7ed 100755 --- a/testbot/tests/TestWTBS +++ b/testbot/tests/TestWTBS @@ -87,10 +87,33 @@ p tests.TestFailures 1 =cut
my $Usage; +sub check_opt_val($$) +{ + my ($option, $val) = @_; + + if (defined $val) + { + error("$option can only be specified once\n"); + $Usage = 2; # but continue processing this option + } + if (!@ARGV) + { + error("missing value for $option\n"); + $Usage = 2; + return undef; + } + return shift @ARGV; +} + +my $OptJobs; while (@ARGV) { my $Arg = shift @ARGV; - if ($Arg eq "--help") + if ($Arg eq "--jobs") + { + $OptJobs = check_opt_val($Arg, $OptJobs); + } + elsif ($Arg eq "--help") { $Usage = 0; } @@ -101,6 +124,30 @@ while (@ARGV) } }
+my @JobRanges; +if (!defined $Usage) +{ + if (defined $OptJobs) + { + foreach my $Range (split /,+/, $OptJobs) + { + if ($Range =~ /^([0-9]+)$/) + { + push @JobRanges, [$1, $1]; + } + elsif ($Range =~ /^([0-9]*)..([0-9]*)/) + { + push @JobRanges, [$1 || 0, $2 || 0]; + } + else + { + error("'$Range' is not a valid job range\n"); + $Usage = 2; + } + } + } +} + if (defined $Usage) { if ($Usage) @@ -108,11 +155,15 @@ if (defined $Usage) error("try '$name0 --help' for more information\n"); exit $Usage; } - print "Usage: $name0 [--help]\n"; + print "Usage: $name0 [--jobs RANGES] [--help]\n"; print "\n"; print "Tests the Patches subject parser.\n"; print "\n"; print "Where:\n"; + print " --jobs RANGES Only check the jobs in one of the specified comma-separated\n"; + print " job id ranges. Each range is either a single job id, or of the\n"; + print " form 'FIRST..LAST' where FIRST and LAST are either the empty\n"; + print " string or a job id.\n"; print " --help Shows this usage message.\n"; exit 0; } @@ -369,6 +420,19 @@ sub CheckJob($$) } }
+sub IsJobInRange($) +{ + my ($Job) = @_; + + return 1 if (!@JobRanges); + foreach my $Range (@JobRanges) + { + return 1 if (($Range->[0] == 0 or $Range->[0] <= $Job->Id) and + ($Range->[1] == 0 or $Job->Id <= $Range->[1])); + } + return 0; +} + =pod
=item <tasks.HasTask> @@ -388,6 +452,7 @@ p win.HasTask 0 sub CheckJobTree($) { my ($Job) = @_; + return if (!IsJobInRange($Job));
my ($TestInfo, $HasTask);