mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
launcher: Allow partionning the tests
This introduce new command line options, --parts and --part-index. When --parts is set to a value larger then 1, the tests will be split in the same number of group. The group number identified by --part-index will be executed. This is being added in orther to support gliblab CI parallel feature.
This commit is contained in:
parent
e4ca67938e
commit
1bc8e92efc
2 changed files with 24 additions and 0 deletions
|
@ -40,6 +40,7 @@ import xml
|
|||
import random
|
||||
import shutil
|
||||
import uuid
|
||||
from itertools import cycle
|
||||
|
||||
from .utils import which
|
||||
from . import reporters
|
||||
|
@ -1866,6 +1867,13 @@ class _TestsLauncher(Loggable):
|
|||
|
||||
return testlist_changed
|
||||
|
||||
def _split_tests(self, num_groups):
|
||||
groups = [[] for x in range(num_groups)]
|
||||
group = cycle(groups)
|
||||
for test in self.tests:
|
||||
next(group).append(test)
|
||||
return groups
|
||||
|
||||
def list_tests(self):
|
||||
for tester in self.testers:
|
||||
if not self._tester_needed(tester):
|
||||
|
@ -1878,6 +1886,15 @@ class _TestsLauncher(Loggable):
|
|||
|
||||
self.tests.extend(tests)
|
||||
self.tests.sort(key=lambda test: test.classname)
|
||||
|
||||
if self.options.num_parts < 1:
|
||||
raise RuntimeError("Tests must be split in positive number of parts.")
|
||||
if self.options.num_parts > len(self.tests):
|
||||
raise RuntimeError("Cannot have more parts then there exist tests.")
|
||||
if self.options.part_index < 1 or self.options.part_index > self.options.num_parts:
|
||||
raise RuntimeError("Part index is out of range")
|
||||
|
||||
self.tests = self._split_tests(self.options.num_parts)[self.options.part_index - 1]
|
||||
return self.tests
|
||||
|
||||
def _tester_needed(self, tester):
|
||||
|
|
|
@ -530,6 +530,13 @@ class LauncherConfig(Loggable):
|
|||
dir_group.add_argument("--ignore-numfailures", dest="ignore_numfailures",
|
||||
help="Ignore the number of failed test in exit code",
|
||||
default=False, action='store_true')
|
||||
dir_group.add_argument("--parts", dest="num_parts",
|
||||
help="Splits the tests in equally distributed parts and only run one part"
|
||||
" (Defaults to 1 part)",
|
||||
type=int, default=1)
|
||||
dir_group.add_argument("--part-index", dest="part_index",
|
||||
help="The index of the part to be run (starts at 1).",
|
||||
type=int, default=1)
|
||||
|
||||
http_server_group = parser.add_argument_group(
|
||||
"Handle the HTTP server to be created")
|
||||
|
|
Loading…
Reference in a new issue