Esempio n. 1
0
 def __init__(self, python=None, **kwargs):
     kwargs = self.setupShellMixin(kwargs, prohibitArgs=['command'])
     super().__init__(**kwargs)
     self.python = python
     self.warningLines = []
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 2
0
    def __init__(self, *args, **kwargs):

        for name, default in [('binary', 'cppcheck'), ('source', ['.']),
                              ('enable', []), ('inconclusive', False),
                              ('extra_args', [])]:
            setattr(self, name, kwargs.pop(name, default))

        ShellCommand.__init__(self, *args, **kwargs)
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))

        command = [self.binary]
        command.extend(self.source)
        if self.enable:
            command.append('--enable=%s' % ','.join(self.enable))
        if self.inconclusive:
            command.append('--inconclusive')
        command.extend(self.extra_args)
        self.setCommand(command)

        counts = self.counts = {}
        summaries = self.summaries = {}
        for m in self.MESSAGES:
            counts[m] = 0
            summaries[m] = []
Esempio n. 3
0
 def __init__(self, store_results=True, **kwargs):
     super().__init__(**kwargs)
     self._store_results = store_results
     self.counts = {}
     self.summaries = {}
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 4
0
    def __init__(self,
                 warningPattern=None, warningExtractor=None, maxWarnCount=None,
                 directoryEnterPattern=None, directoryLeavePattern=None,
                 suppressionFile=None, **kwargs):
        # See if we've been given a regular expression to use to match
        # warnings. If not, use a default that assumes any line with "warning"
        # present is a warning. This may lead to false positives in some cases.
        if warningPattern:
            self.warningPattern = warningPattern
        if directoryEnterPattern:
            self.directoryEnterPattern = directoryEnterPattern
        if directoryLeavePattern:
            self.directoryLeavePattern = directoryLeavePattern
        if suppressionFile:
            self.suppressionFile = suppressionFile
        if warningExtractor:
            self.warningExtractor = warningExtractor
        else:
            self.warningExtractor = WarningCountingShellCommand.warnExtractWholeLine
        self.maxWarnCount = maxWarnCount

        # And upcall to let the base class do its work
        ShellCommand.__init__(self, **kwargs)

        self.suppressions = []
        self.directoryStack = []

        self.warnCount = 0
        self.loggedWarnings = []

        self.addLogObserver(
            'stdio',
            logobserver.LineConsumerLogObserver(self.warningLogConsumer))
Esempio n. 5
0
    def __init__(self,
                 architecture=None,
                 distribution=None,
                 basetgz=None,
                 mirror=None,
                 extrapackages=None,
                 keyring=None,
                 components=None,
                 **kwargs):
        super().__init__(**kwargs)

        if architecture:
            self.architecture = architecture
        if distribution:
            self.distribution = distribution
        if mirror:
            self.mirror = mirror
        if extrapackages:
            self.extrapackages = extrapackages
        if keyring:
            self.keyring = keyring
        if components:
            self.components = components
        if basetgz:
            self.basetgz = basetgz

        if not self.distribution:
            config.error("You must specify a distribution.")

        self.suppressions.append(
            (None, re.compile(r"\.pbuilderrc does not exist"), None, None))

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 6
0
    def __init__(self, spec=None, sources=None, **kwargs):
        """
        Creates the MockBuildSRPM object.

        @type spec: str
        @param spec: the path of the specfiles.
        @type sources: str
        @param sources: the path of the sources dir.
        @type kwargs: dict
        @param kwargs: All further keyword arguments.
        """
        Mock.__init__(self, **kwargs)
        if spec:
            self.spec = spec
        if sources:
            self.sources = sources

        if not self.spec:
            config.error("You must specify a spec file")
        if not self.sources:
            config.error("You must specify a sources dir")

        self.command += [
            '--buildsrpm', '--spec', self.spec, '--sources', self.sources
        ]
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 7
0
    def start(self):
        if self.autoRelease:
            relfile = '%s.release' % (os.path.basename(
                self.specfile).split('.')[0])
            try:
                with open(relfile, 'r') as rfile:
                    rel = int(rfile.readline().strip())
            except (IOError, TypeError, ValueError):
                rel = 0
            self.rpmbuild = self.rpmbuild + ' --define "_release %s"' % rel
            with open(relfile, 'w') as rfile:
                rfile.write(str(rel + 1))

        if self.vcsRevision:
            revision = self.getProperty('got_revision')
            # only do this in the case where there's a single codebase
            if revision and not isinstance(revision, dict):
                self.rpmbuild = (self.rpmbuild +
                                 ' --define "_revision %s"' % revision)

        self.rpmbuild = self.rpmbuild + ' -ba %s' % self.specfile

        self.command = self.rpmbuild

        # create the actual RemoteShellCommand instance now
        kwargs = self.remote_kwargs
        kwargs['command'] = self.command
        kwargs['workdir'] = self.workdir
        cmd = buildstep.RemoteShellCommand(**kwargs)
        self.setupEnvironment(cmd)
        self.startCommand(cmd)
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 8
0
 def __init__(self, store_results=True, **kwargs):
     kwargs = self.setupShellMixin(kwargs)
     super().__init__(**kwargs)
     self._store_results = store_results
     self.counts = {}
     self.summaries = {}
     self.addLogObserver('stdio', logobserver.LineConsumerLogObserver(self._log_consumer))
Esempio n. 9
0
    def __init__(self,
                 sphinx_sourcedir='.',
                 sphinx_builddir=None,
                 sphinx_builder=None,
                 sphinx='sphinx-build',
                 tags=None,
                 defines=None,
                 strict_warnings=False,
                 mode='incremental',
                 **kwargs):

        if tags is None:
            tags = []

        if defines is None:
            defines = {}

        if sphinx_builddir is None:
            # Who the heck is not interested in the built doc ?
            config.error("Sphinx argument sphinx_builddir is required")

        if mode not in ('incremental', 'full'):
            config.error("Sphinx argument mode has to be 'incremental' or" +
                         "'full' is required")

        self.success = False

        kwargs = self.setupShellMixin(kwargs)

        super().__init__(**kwargs)

        # build the command
        command = [sphinx]
        if sphinx_builder is not None:
            command.extend(['-b', sphinx_builder])

        for tag in tags:
            command.extend(['-t', tag])

        for key in sorted(defines):
            if defines[key] is None:
                command.extend(['-D', key])
            elif isinstance(defines[key], bool):
                command.extend(
                    ['-D', '{}={}'.format(key, defines[key] and 1 or 0)])
            else:
                command.extend(['-D', '{}={}'.format(key, defines[key])])

        if mode == 'full':
            command.extend(['-E'])  # Don't use a saved environment

        if strict_warnings:
            command.extend(['-W'])  # Convert warnings to errors

        command.extend([sphinx_sourcedir, sphinx_builddir])
        self.command = command

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self._log_consumer))
Esempio n. 10
0
    def run(self):
        self.addLogObserver('xx', logobserver.LineConsumerLogObserver(self.log_consumer))

        _log = yield self.addLog('xx')
        yield _log.addStdout('line1\nline2\n')
        yield _log.finish()

        return results.SUCCESS
Esempio n. 11
0
    def __init__(self,
                 specfile=None,
                 topdir='`pwd`',
                 builddir='`pwd`',
                 rpmdir='`pwd`',
                 sourcedir='`pwd`',
                 specdir='`pwd`',
                 srcrpmdir='`pwd`',
                 dist='.el6',
                 autoRelease=False,
                 vcsRevision=False,
                 **kwargs):
        """
        Create the RpmBuild object.

        @type specfile: str
        @param specfile: location of the specfile to build
        @type topdir: str
        @param topdir: define the _topdir rpm parameter
        @type builddir: str
        @param builddir: define the _builddir rpm parameter
        @type rpmdir: str
        @param rpmdir: define the _rpmdir rpm parameter
        @type sourcedir: str
        @param sourcedir: define the _sourcedir rpm parameter
        @type specdir: str
        @param specdir: define the _specdir rpm parameter
        @type srcrpmdir: str
        @param srcrpmdir: define the _srcrpmdir rpm parameter
        @type dist: str
        @param dist: define the dist string.
        @type autoRelease: boolean
        @param autoRelease: Use auto incrementing release numbers.
        @type vcsRevision: boolean
        @param vcsRevision: Use vcs version number as revision number.
        """
        ShellCommand.__init__(self, **kwargs)

        self.dist = dist

        self.base_rpmbuild = (
            'rpmbuild --define "_topdir %s" --define "_builddir %s"'
            ' --define "_rpmdir %s" --define "_sourcedir %s"'
            ' --define "_specdir %s" --define "_srcrpmdir %s"'
            % (topdir, builddir, rpmdir, sourcedir, specdir,
               srcrpmdir))

        self.specfile = specfile
        self.autoRelease = autoRelease
        self.vcsRevision = vcsRevision

        if not self.specfile:
            config.error("You must specify a specfile")

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 12
0
    def __init__(self,
                 warningPattern=None,
                 warningExtractor=None,
                 maxWarnCount=None,
                 directoryEnterPattern=None,
                 directoryLeavePattern=None,
                 suppressionFile=None,
                 suppressionList=None,
                 **kwargs):
        # See if we've been given a regular expression to use to match
        # warnings. If not, use a default that assumes any line with "warning"
        # present is a warning. This may lead to false positives in some cases.
        if warningPattern:
            self.warningPattern = warningPattern
        if directoryEnterPattern:
            self.directoryEnterPattern = directoryEnterPattern
        if directoryLeavePattern:
            self.directoryLeavePattern = directoryLeavePattern
        if suppressionFile:
            self.suppressionFile = suppressionFile
        # self.suppressions is already taken, so use something else
        self.suppressionList = suppressionList
        if warningExtractor:
            self.warningExtractor = warningExtractor
        else:
            self.warningExtractor = WarningCountingShellCommand.warnExtractWholeLine
        self.maxWarnCount = maxWarnCount

        # And upcall to let the base class do its work
        super().__init__(**kwargs)

        if self.__class__ is WarningCountingShellCommand and \
                not kwargs.get('command'):
            # WarningCountingShellCommand class is directly instantiated.
            # Explicitly check that command is set to prevent runtime error
            # later.
            config.error("WarningCountingShellCommand's `command' argument "
                         "is not specified")

        self.suppressions = []
        self.directoryStack = []

        self.warnCount = 0
        self.loggedWarnings = []

        self.addLogObserver(
            'stdio',
            logobserver.LineConsumerLogObserver(self.warningLogConsumer))

        if self.__class__.__name__ not in [
                'Compile', 'Test', 'DebPbuilder', 'DebCowbuilder',
                'UbuPbuilder'
        ]:
            self.warn_deprecated_if_oldstyle_subclass(
                'WarningCountingShellCommand')
Esempio n. 13
0
    def do_test_sequence(self, consumer):
        logid = yield self.master.data.updates.addLog(1, 'mine', 's')
        _log = log.Log.new(self.master, 'mine', 's', logid, 'utf-8')
        lo = logobserver.LineConsumerLogObserver(consumer)
        lo.setLog(_log)

        yield _log.addStdout('hello\n')
        yield _log.addStderr('cruel\n')
        yield _log.addStdout('multi\nline\nchunk\n')
        yield _log.addHeader('H1\nH2\n')
        yield _log.finish()
Esempio n. 14
0
 def __init__(self, **kwargs):
     kwargs = self.setupShellMixin(kwargs)
     super().__init__(**kwargs)
     self.addLogObserver(
         'stdio',
         logobserver.LineConsumerLogObserver(self.log_line_consumer))
     self.total_count = 0
     self.skipped_count = 0
     self.fails_count = 0
     self.errors_count = 0
     self.has_tests = False
Esempio n. 15
0
    def __init__(self, *args, **kwargs):
        # PyFlakes return 1 for both warnings and errors. We
        # categorize this initially as WARNINGS so that
        # evaluateCommand below can inspect the results more closely.
        kwargs['decodeRC'] = {0: SUCCESS, 1: WARNINGS}
        ShellCommand.__init__(self, *args, **kwargs)
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))

        counts = self.counts = {}
        summaries = self.summaries = {}
        for m in self.MESSAGES:
            counts[m] = 0
            summaries[m] = []
Esempio n. 16
0
    def __init__(self,
                 warningPattern=None,
                 warningExtractor=None,
                 maxWarnCount=None,
                 directoryEnterPattern=None,
                 directoryLeavePattern=None,
                 suppressionFile=None,
                 suppressionList=None,
                 **kwargs):
        # See if we've been given a regular expression to use to match
        # warnings. If not, use a default that assumes any line with "warning"
        # present is a warning. This may lead to false positives in some cases.
        if warningPattern:
            self.warningPattern = warningPattern
        if directoryEnterPattern:
            self.directoryEnterPattern = directoryEnterPattern
        if directoryLeavePattern:
            self.directoryLeavePattern = directoryLeavePattern
        if suppressionFile:
            self.suppressionFile = suppressionFile
        # self.suppressions is already taken, so use something else
        self.suppressionList = suppressionList
        if warningExtractor:
            self.warningExtractor = warningExtractor
        else:
            self.warningExtractor = WarningCountingShellCommand.warnExtractWholeLine
        self.maxWarnCount = maxWarnCount

        if self.__class__ is WarningCountingShellCommandNewStyle and \
                not kwargs.get('command'):
            # WarningCountingShellCommandNewStyle class is directly instantiated.
            # Explicitly check that command is set to prevent runtime error
            # later.
            config.error(
                "WarningCountingShellCommandNewStyle's `command' argument "
                "is not specified")

        kwargs = self.setupShellMixin(kwargs)
        super().__init__(**kwargs)

        self.suppressions = []
        self.directoryStack = []

        self.warnCount = 0
        self.loggedWarnings = []

        self.addLogObserver(
            'stdio',
            logobserver.LineConsumerLogObserver(self.warningLogConsumer))
Esempio n. 17
0
    def __init__(self, **kwargs):
        # Inject standard tags into the environment.
        env = {
            'BUILDBOT_BLAMELIST':
            util.Interpolate('%(prop:blamelist:-[])s'),
            'BUILDBOT_BRANCH':
            util.Interpolate('%(prop:branch:-None)s'),
            'BUILDBOT_BUILDERNAME':
            util.Interpolate('%(prop:buildername:-None)s'),
            'BUILDBOT_BUILDNUMBER':
            util.Interpolate('%(prop:buildnumber:-None)s'),
            'BUILDBOT_CLOBBER':
            util.Interpolate('%(prop:clobber:+1)s'),
            'BUILDBOT_GOT_REVISION':
            util.Interpolate('%(prop:got_revision:-None)s'),
            'BUILDBOT_REVISION':
            util.Interpolate('%(prop:revision:-None)s'),
            'BUILDBOT_SCHEDULER':
            util.Interpolate('%(prop:scheduler:-None)s'),
            'BUILDBOT_SLAVENAME':
            util.Interpolate('%(prop:slavename:-None)s'),
            'BUILDBOT_MSAN_ORIGINS':
            util.Interpolate('%(prop:msan_origins:-)s'),
        }
        # Apply the passed in environment on top.
        old_env = kwargs.get('env') or {}
        env.update(old_env)
        # Change passed in args (ok as a copy is made internally).
        kwargs['env'] = env

        kwargs = self.setupShellMixin(kwargs)
        super().__init__(**kwargs)

        self.addLogObserver(
            'stdio',
            logobserver.LineConsumerLogObserver(self.processAnnotations))
        # A step log to store all logs, which we got before the first @@@BUILD_STEP @@@ command.
        self.preamble_log = None

        self.annotate_status = results.SUCCESS
        self.halt_on_failure = False
        self.honor_zero_return_code = False

        self.annotated_steps = []
        # Use this lock to "run" the annotated steps.
        self.initLock = defer.DeferredLock()
        self._annotated_finished = False
Esempio n. 18
0
    def __init__(self,
                 sphinx_sourcedir='.',
                 sphinx_builddir=None,
                 sphinx_builder=None,
                 sphinx='sphinx-build',
                 tags=[],
                 defines={},
                 mode='incremental',
                 **kwargs):

        if sphinx_builddir is None:
            # Who the heck is not interested in the built doc ?
            config.error("Sphinx argument sphinx_builddir is required")

        if mode not in ('incremental', 'full'):
            config.error("Sphinx argument mode has to be 'incremental' or" +
                         "'full' is required")

        self.success = False
        ShellCommand.__init__(self, **kwargs)

        # build the command
        command = [sphinx]
        if sphinx_builder is not None:
            command.extend(['-b', sphinx_builder])

        for tag in tags:
            command.extend(['-t', tag])

        for key in sorted(defines):
            if defines[key] is None:
                command.extend(['-D', key])
            elif isinstance(defines[key], bool):
                command.extend(
                    ['-D', '%s=%d' % (key, defines[key] and 1 or 0)])
            else:
                command.extend(['-D', '%s=%s' % (key, defines[key])])

        if mode == 'full':
            command.extend(['-E'])  # Don't use a saved environment

        command.extend([sphinx_sourcedir, sphinx_builddir])
        self.setCommand(command)

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 19
0
    def __init__(self, *args, **kwargs):

        for name, default in [('binary', 'cppcheck'), ('source', ['.']),
                              ('enable', []), ('inconclusive', False),
                              ('extra_args', [])]:
            setattr(self, name, kwargs.pop(name, default))

        kwargs = self.setupShellMixin(kwargs, prohibitArgs=['command'])
        super().__init__(*args, **kwargs)
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self._log_consumer))

        self.counts = {}
        summaries = self.summaries = {}
        for m in self.MESSAGES:
            self.counts[m] = 0
            summaries[m] = []
Esempio n. 20
0
    def start(self):

        rpm_extras_dict = {}
        rpm_extras_dict['dist'] = self.dist

        if self.autoRelease:
            relfile = '%s.release' % (os.path.basename(
                self.specfile).split('.')[0])
            try:
                with open(relfile, 'r') as rfile:
                    rel = int(rfile.readline().strip())
            except (IOError, TypeError, ValueError):
                rel = 0
            rpm_extras_dict['_release'] = rel
            with open(relfile, 'w') as rfile:
                rfile.write(str(rel + 1))

        if self.vcsRevision:
            revision = self.getProperty('got_revision')
            # only do this in the case where there's a single codebase
            if revision and not isinstance(revision, dict):
                rpm_extras_dict['_revision'] = revision

        self.rpmbuild = self.base_rpmbuild

        # The unit tests expect a certain order, so we sort the dict to keep
        # format the same every time
        for k, v in sorted(iteritems(rpm_extras_dict)):
            self.rpmbuild = '{0} --define "{1} {2}"'.format(
                self.rpmbuild, k, v)

        self.rpmbuild = '{0} -ba {1}'.format(self.rpmbuild, self.specfile)

        self.command = self.rpmbuild

        # create the actual RemoteShellCommand instance now
        kwargs = self.remote_kwargs
        kwargs['command'] = self.command
        kwargs['workdir'] = self.workdir
        cmd = buildstep.RemoteShellCommand(**kwargs)
        self.setupEnvironment(cmd)
        self.startCommand(cmd)
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 21
0
    def __init__(self, *args, **kwargs):
        # PyFlakes return 1 for both warnings and errors. We
        # categorize this initially as WARNINGS so that
        # evaluateCommand below can inspect the results more closely.
        kwargs['decodeRC'] = {0: SUCCESS, 1: WARNINGS}

        kwargs = self.setupShellMixin(kwargs)
        super().__init__(*args, **kwargs)

        self.addLogObserver('stdio', logobserver.LineConsumerLogObserver(self._log_consumer))

        counts = self.counts = {}
        summaries = self.summaries = {}
        for m in self._MESSAGES:
            counts[m] = 0
            summaries[m] = []

        # we need a separate variable for syntax errors
        self._hasSyntaxError = False
Esempio n. 22
0
    def __init__(self,
                 specfile=None,
                 topdir='`pwd`',
                 builddir='`pwd`',
                 rpmdir='`pwd`',
                 sourcedir='`pwd`',
                 specdir='`pwd`',
                 srcrpmdir='`pwd`',
                 dist='.el6',
                 define=None,
                 autoRelease=False,
                 vcsRevision=False,
                 **kwargs):
        kwargs = self.setupShellMixin(kwargs, prohibitArgs=['command'])
        super().__init__(**kwargs)

        self.dist = dist

        self.base_rpmbuild = (
            f'rpmbuild --define "_topdir {topdir}" --define "_builddir {builddir}"'
            f' --define "_rpmdir {rpmdir}" --define "_sourcedir {sourcedir}"'
            f' --define "_specdir {specdir}" --define "_srcrpmdir {srcrpmdir}"'
        )

        if define is None:
            define = {}
        for k, v in define.items():
            self.base_rpmbuild += f" --define \"{k} {v}\""

        self.specfile = specfile
        self.autoRelease = autoRelease
        self.vcsRevision = vcsRevision

        if not self.specfile:
            config.error("You must specify a specfile")

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 23
0
 def __init__(self, **kwargs: Any) -> None:
     super().__init__(**kwargs)
     self.addLogObserver(
         "stdio", logobserver.LineConsumerLogObserver(self.check_pr_exists)
     )
Esempio n. 24
0
 def __init__(self, python=None, **kwargs):
     ShellCommand.__init__(self, **kwargs)
     self.python = python
     self.warningLines = []
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 25
0
    def __init__(self,
                 reactor=UNSPECIFIED,
                 python=None,
                 trial=None,
                 testpath=UNSPECIFIED,
                 tests=None,
                 testChanges=None,
                 recurse=None,
                 randomly=None,
                 trialMode=None,
                 trialArgs=None,
                 jobs=None,
                 **kwargs):
        """
        @type  testpath: string
        @param testpath: use in PYTHONPATH when running the tests. If
                         None, do not set PYTHONPATH. Setting this to '.' will
                         cause the source files to be used in-place.

        @type  python: string (without spaces) or list
        @param python: which python executable to use. Will form the start of
                       the argv array that will launch trial. If you use this,
                       you should set 'trial' to an explicit path (like
                       /usr/bin/trial or ./bin/trial). Defaults to None, which
                       leaves it out entirely (running 'trial args' instead of
                       'python ./bin/trial args'). Likely values are 'python',
                       ['python2.2'], ['python', '-Wall'], etc.

        @type  trial: string
        @param trial: which 'trial' executable to run.
                      Defaults to 'trial', which will cause $PATH to be
                      searched and probably find /usr/bin/trial . If you set
                      'python', this should be set to an explicit path (because
                      'python2.3 trial' will not work).

        @type trialMode: list of strings
        @param trialMode: a list of arguments to pass to trial, specifically
                          to set the reporting mode. This defaults to ['-to']
                          which means 'verbose colorless output' to the trial
                          that comes with Twisted-2.0.x and at least -2.1.0 .
                          Newer versions of Twisted may come with a trial
                          that prefers ['--reporter=bwverbose'].

        @type trialArgs: list of strings
        @param trialArgs: a list of arguments to pass to trial, available to
                          turn on any extra flags you like. Defaults to [].

        @type jobs: integer
        @param jobs: integer to be used as trial -j/--jobs option (for
                     running tests on several workers).  Only supported
                     since Twisted-12.3.0.

        @type  tests: list of strings
        @param tests: a list of test modules to run, like
                      ['twisted.test.test_defer', 'twisted.test.test_process'].
                      If this is a string, it will be converted into a one-item
                      list.

        @type  testChanges: boolean
        @param testChanges: if True, ignore the 'tests' parameter and instead
                            ask the Build for all the files that make up the
                            Changes going into this build. Pass these filenames
                            to trial and ask it to look for test-case-name
                            tags, running just the tests necessary to cover the
                            changes.

        @type  recurse: boolean
        @param recurse: If True, pass the --recurse option to trial, allowing
                        test cases to be found in deeper subdirectories of the
                        modules listed in 'tests'. This does not appear to be
                        necessary when using testChanges.

        @type  reactor: string
        @param reactor: which reactor to use, like 'gtk' or 'java'. If not
                        provided, the Twisted's usual platform-dependent
                        default is used.

        @type  randomly: boolean
        @param randomly: if True, add the --random=0 argument, which instructs
                         trial to run the unit tests in a random order each
                         time. This occasionally catches problems that might be
                         masked when one module always runs before another
                         (like failing to make registerAdapter calls before
                         lookups are done).

        @type  kwargs: dict
        @param kwargs: parameters. The following parameters are inherited from
                       L{ShellCommand} and may be useful to set: workdir,
                       haltOnFailure, flunkOnWarnings, flunkOnFailure,
                       warnOnWarnings, warnOnFailure, want_stdout, want_stderr,
                       timeout.
        """
        ShellCommand.__init__(self, **kwargs)

        if python:
            self.python = python
        if self.python is not None:
            if isinstance(self.python, str):
                self.python = [self.python]
            for s in self.python:
                if " " in s:
                    # this is not strictly an error, but I suspect more
                    # people will accidentally try to use python="python2.3
                    # -Wall" than will use embedded spaces in a python flag
                    log.msg("python= component '%s' has spaces")
                    log.msg("To add -Wall, use python=['python', '-Wall']")
                    why = "python= value has spaces, probably an error"
                    raise ValueError(why)

        if trial:
            self.trial = trial
        if " " in self.trial:
            raise ValueError("trial= value has spaces")
        if trialMode is not None:
            self.trialMode = trialMode
        if trialArgs is not None:
            self.trialArgs = trialArgs
        if jobs is not None:
            self.jobs = jobs

        if testpath is not UNSPECIFIED:
            self.testpath = testpath
        if self.testpath is UNSPECIFIED:
            raise ValueError("You must specify testpath= (it can be None)")
        assert isinstance(self.testpath, str) or self.testpath is None

        if reactor is not UNSPECIFIED:
            self.reactor = reactor

        if tests is not None:
            self.tests = tests
        if isinstance(self.tests, str):
            self.tests = [self.tests]
        if testChanges is not None:
            self.testChanges = testChanges
            # self.recurse = True  # not sure this is necessary

        if not self.testChanges and self.tests is None:
            raise ValueError("Must either set testChanges= or provide tests=")

        if recurse is not None:
            self.recurse = recurse
        if randomly is not None:
            self.randomly = randomly

        # build up most of the command, then stash it until start()
        command = []
        if self.python:
            command.extend(self.python)
        command.append(self.trial)
        command.extend(self.trialMode)
        if self.recurse:
            command.append("--recurse")
        if self.reactor:
            command.append("--reactor=%s" % reactor)
        if self.randomly:
            command.append("--random=0")
        command.extend(self.trialArgs)
        self.command = command

        if self.reactor:
            self.description = ["testing", "(%s)" % self.reactor]
            self.descriptionDone = ["tests"]
            # commandComplete adds (reactorname) to self.text
        else:
            self.description = ["testing"]
            self.descriptionDone = ["tests"]

        # this counter will feed Progress along the 'test cases' metric
        self.observer = TrialTestCaseCounter()
        self.addLogObserver('stdio', self.observer)

        # this observer consumes multiple lines in a go, so it can't be easily
        # handled in TrialTestCaseCounter.
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
        self.problems = []
        self.warnings = {}

        # text used before commandComplete runs
        self.text = 'running'
Esempio n. 26
0
 def __init__(self, **kwargs):
     kwargs = self.setupShellMixin(kwargs)
     super().__init__(**kwargs)
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self._log_consumer))
Esempio n. 27
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 28
0
    def __init__(self,
                 reactor=UNSPECIFIED,
                 python=None,
                 trial=None,
                 testpath=UNSPECIFIED,
                 tests=None,
                 testChanges=None,
                 recurse=None,
                 randomly=None,
                 trialMode=None,
                 trialArgs=None,
                 jobs=None,
                 **kwargs):

        kwargs = self.setupShellMixin(kwargs, prohibitArgs=['command'])
        super().__init__(**kwargs)

        if python:
            self.python = python
        if self.python is not None:
            if isinstance(self.python, str):
                self.python = [self.python]
            for s in self.python:
                if " " in s:
                    # this is not strictly an error, but I suspect more
                    # people will accidentally try to use python="python2.3
                    # -Wall" than will use embedded spaces in a python flag
                    log.msg("python= component '%s' has spaces")
                    log.msg("To add -Wall, use python=['python', '-Wall']")
                    why = "python= value has spaces, probably an error"
                    raise ValueError(why)

        if trial:
            self.trial = trial
        if " " in self.trial:
            raise ValueError("trial= value has spaces")
        if trialMode is not None:
            self.trialMode = trialMode
        if trialArgs is not None:
            self.trialArgs = trialArgs
        if jobs is not None:
            self.jobs = jobs

        if testpath is not UNSPECIFIED:
            self.testpath = testpath
        if self.testpath is UNSPECIFIED:
            raise ValueError("You must specify testpath= (it can be None)")
        assert isinstance(self.testpath, str) or self.testpath is None

        if reactor is not UNSPECIFIED:
            self.reactor = reactor

        if tests is not None:
            self.tests = tests
        if isinstance(self.tests, str):
            self.tests = [self.tests]
        if testChanges is not None:
            self.testChanges = testChanges
            # self.recurse = True  # not sure this is necessary

        if not self.testChanges and self.tests is None:
            raise ValueError("Must either set testChanges= or provide tests=")

        if recurse is not None:
            self.recurse = recurse
        if randomly is not None:
            self.randomly = randomly

        if self.reactor:
            self.description = "testing ({})".format(self.reactor)

        # this counter will feed Progress along the 'test cases' metric
        self.observer = TrialTestCaseCounter()
        self.addLogObserver('stdio', self.observer)

        # this observer consumes multiple lines in a go, so it can't be easily
        # handled in TrialTestCaseCounter.
        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
        self.problems = []
        self.warnings = {}

        # text used before commandComplete runs
        self.text = 'running'
Esempio n. 29
0
 def __init__(self, **kwargs):
     ShellCommand.__init__(self, **kwargs)
     self.addLogObserver(
         'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))
Esempio n. 30
0
    def __init__(self,
                 architecture=None,
                 distribution=None,
                 basetgz=None,
                 mirror=None,
                 extrapackages=None,
                 keyring=None,
                 components=None,
                 **kwargs):
        """
        Creates the DebPbuilder object.

        @type architecture: str
        @param architecture: the name of the architecture to build
        @type distribution: str
        @param distribution: the man of the distribution to use
        @type basetgz: str
        @param basetgz: the path or  path template of the basetgz
        @type mirror: str
        @param mirror: the mirror for building basetgz
        @type extrapackages: list
        @param extrapackages: adds packages specified to buildroot
        @type keyring: str
        @param keyring: keyring file to use for verification
        @type components: str
        @param components: components to use for chroot creation
        @type kwargs: dict
        @param kwargs: All further keyword arguments.
        """
        WarningCountingShellCommand.__init__(self, **kwargs)

        if architecture:
            self.architecture = architecture
        if distribution:
            self.distribution = distribution
        if mirror:
            self.mirror = mirror
        if extrapackages:
            self.extrapackages = extrapackages
        if keyring:
            self.keyring = keyring
        if components:
            self.components = components

        if self.architecture:
            kwargs['architecture'] = self.architecture
        else:
            kwargs['architecture'] = 'local'
        kwargs['distribution'] = self.distribution

        if basetgz:
            self.basetgz = basetgz % kwargs
        else:
            self.basetgz = self.basetgz % kwargs

        if not self.distribution:
            config.error("You must specify a distribution.")

        self.command = [
            'pdebuild', '--buildresult', '.', '--pbuilder', self.pbuilder
        ]
        if self.architecture:
            self.command += ['--architecture', self.architecture]
        self.command += [
            '--', '--buildresult', '.', self.baseOption, self.basetgz
        ]
        if self.extrapackages:
            self.command += ['--extrapackages', " ".join(self.extrapackages)]

        self.suppressions.append(
            (None, re.compile(r"\.pbuilderrc does not exist"), None, None))

        self.addLogObserver(
            'stdio', logobserver.LineConsumerLogObserver(self.logConsumer))