예제 #1
0
    def __init__(self, **kwargs):
        self.worker = None

        for p in self.__class__.parms:
            if p in kwargs:
                setattr(self, p, kwargs.pop(p))

        if kwargs:
            config.error(
                f"{self.__class__}.__init__ got unexpected keyword argument(s) "
                f"{list(kwargs)}")
        self._pendingLogObservers = []

        if not isinstance(self.name, str) and not IRenderable.providedBy(
                self.name):
            config.error(
                f"BuildStep name must be a string or a renderable object: "
                f"{repr(self.name)}")

        check_param_length(self.name, f'Step {self.__class__.__name__} name',
                           Model.steps.c.name.type.length)

        if isinstance(self.description, str):
            self.description = [self.description]
        if isinstance(self.descriptionDone, str):
            self.descriptionDone = [self.descriptionDone]
        if isinstance(self.descriptionSuffix, str):
            self.descriptionSuffix = [self.descriptionSuffix]

        if self.updateBuildSummaryPolicy is None:
            # compute default value for updateBuildSummaryPolicy
            self.updateBuildSummaryPolicy = [EXCEPTION, RETRY, CANCELLED]
            if self.flunkOnFailure or self.haltOnFailure or self.warnOnFailure:
                self.updateBuildSummaryPolicy.append(FAILURE)
            if self.warnOnWarnings or self.flunkOnWarnings:
                self.updateBuildSummaryPolicy.append(WARNINGS)
        if self.updateBuildSummaryPolicy is False:
            self.updateBuildSummaryPolicy = []
        if self.updateBuildSummaryPolicy is True:
            self.updateBuildSummaryPolicy = ALL_RESULTS
        if not isinstance(self.updateBuildSummaryPolicy, list):
            config.error("BuildStep updateBuildSummaryPolicy must be "
                         "a list of result ids or boolean but it is "
                         f"{repr(self.updateBuildSummaryPolicy)}")
        self._acquiringLocks = []
        self.stopped = False
        self.master = None
        self.statistics = {}
        self.logs = {}
        self._running = False
        self.stepid = None
        self.results = None
        self._start_unhandled_deferreds = None
        self._test_result_submitters = {}
예제 #2
0
    def __init__(self, name=None, workername=None, workernames=None,
                 builddir=None, workerbuilddir=None, factory=None,
                 tags=None,
                 nextWorker=None, nextBuild=None, locks=None, env=None,
                 properties=None, collapseRequests=None, description=None,
                 canStartBuild=None, defaultProperties=None
                 ):
        # name is required, and can't start with '_'
        if not name or type(name) not in (bytes, str):
            error("builder's name is required")
            name = '<unknown>'
        elif name[0] == '_' and name not in RESERVED_UNDERSCORE_NAMES:
            error(f"builder names must not start with an underscore: '{name}'")
        try:
            self.name = bytes2unicode(name, encoding="ascii")
        except UnicodeDecodeError:
            error("builder names must be unicode or ASCII")

        # factory is required
        if factory is None:
            error(f"builder '{name}' has no factory")
        from buildbot.process.factory import BuildFactory
        if factory is not None and not isinstance(factory, BuildFactory):
            error(f"builder '{name}'s factory is not a BuildFactory instance")
        self.factory = factory

        # workernames can be a single worker name or a list, and should also
        # include workername, if given
        if isinstance(workernames, str):
            workernames = [workernames]
        if workernames:
            if not isinstance(workernames, list):
                error(f"builder '{name}': workernames must be a list or a string")
        else:
            workernames = []

        if workername:
            if not isinstance(workername, str):
                error(f"builder '{name}': workername must be a string but it is {repr(workername)}")
            workernames = workernames + [workername]
        if not workernames:
            error(f"builder '{name}': at least one workername is required")

        self.workernames = workernames

        # builddir defaults to name
        if builddir is None:
            builddir = safeTranslate(name)
            builddir = bytes2unicode(builddir)
        self.builddir = builddir

        # workerbuilddir defaults to builddir
        if workerbuilddir is None:
            workerbuilddir = builddir
        self.workerbuilddir = workerbuilddir

        # remainder are optional
        if tags:
            if not isinstance(tags, list):
                error(f"builder '{name}': tags must be a list")
            bad_tags = any((tag for tag in tags if not isinstance(tag, str)))
            if bad_tags:
                error(f"builder '{name}': tags list contains something that is not a string")

            if len(tags) != len(set(tags)):
                dupes = " ".join({x for x in tags if tags.count(x) > 1})
                error(f"builder '{name}': tags list contains duplicate tags: {dupes}")
        else:
            tags = []

        self.tags = tags

        self.nextWorker = nextWorker
        if nextWorker and not callable(nextWorker):
            error('nextWorker must be a callable')
        self.nextBuild = nextBuild
        if nextBuild and not callable(nextBuild):
            error('nextBuild must be a callable')
        self.canStartBuild = canStartBuild
        if canStartBuild and not callable(canStartBuild):
            error('canStartBuild must be a callable')

        self.locks = locks or []
        self.env = env or {}
        if not isinstance(self.env, dict):
            error("builder's env must be a dictionary")

        self.properties = properties or {}
        for property_name in self.properties:
            check_param_length(property_name, f'Builder {self.name} property',
                               Model.property_name_length)

        self.defaultProperties = defaultProperties or {}
        for property_name in self.defaultProperties:
            check_param_length(property_name, f'Builder {self.name} default property',
                               Model.property_name_length)

        self.collapseRequests = collapseRequests

        self.description = description
예제 #3
0
 def test_long_interpolate(self):
     with self.assertRaisesConfigError("xceeds maximum length of 10"):
         check_param_length(Interpolate('123456%(prop:xy)s78901'),
                            'Step name', 10)
예제 #4
0
 def test_short_interpolate_kwargs(self):
     check_param_length(Interpolate('123456%(prop:xy)s7890', kw='arg'),
                        'Step name', 10)
예제 #5
0
 def test_short_interpolate_args(self):
     check_param_length(Interpolate('123456%s7890', 'arg'), 'Step name', 10)
예제 #6
0
 def test_long_string(self):
     with self.assertRaisesConfigError("exceeds maximum length of 10"):
         check_param_length('12345678901', 'Step name', 10)
예제 #7
0
 def test_short_string(self):
     check_param_length('1234567890', 'Step name', 10)