Ejemplo n.º 1
0
 def __init__(self, config, *args, **kwargs):
     self.config = config
     kwargs = {
         'processOutputLine': [self.process_line],
         'universal_newlines': True,
     }
     ProcessHandlerMixin.__init__(self, *args, **kwargs)
Ejemplo n.º 2
0
    def __init__(self, config, *args, **kwargs):
        self.config = config
        self.results = []

        kwargs['universal_newlines'] = True
        kwargs['processOutputLine'] = [self.process_line]
        ProcessHandlerMixin.__init__(self, *args, **kwargs)
Ejemplo n.º 3
0
    def gtest(self, shuffle, jobs, gtest_filter, tbpl_parser):

        # We lazy build gtest because it's slow to link
        self._run_make(directory="testing/gtest",
                       target='gtest',
                       ensure_exit_code=True)

        app_path = self.get_binary_path('app')

        # Use GTest environment variable to control test execution
        # For details see:
        # https://code.google.com/p/googletest/wiki/AdvancedGuide#Running_Test_Programs:_Advanced_Options
        gtest_env = {b'GTEST_FILTER': gtest_filter}

        gtest_env[b"MOZ_RUN_GTEST"] = b"True"

        if shuffle:
            gtest_env[b"GTEST_SHUFFLE"] = b"True"

        if tbpl_parser:
            gtest_env[b"MOZ_TBPL_PARSER"] = b"True"

        if jobs == 1:
            return self.run_process([app_path, "-unittest"],
                                    append_env=gtest_env,
                                    ensure_exit_code=False,
                                    pass_thru=True)

        from mozprocess import ProcessHandlerMixin
        import functools

        def handle_line(job_id, line):
            # Prepend the jobId
            line = '[%d] %s' % (job_id + 1, line.strip())
            self.log(logging.INFO, "GTest", {'line': line}, '{line}')

        gtest_env["GTEST_TOTAL_SHARDS"] = str(jobs)
        processes = {}
        for i in range(0, jobs):
            gtest_env["GTEST_SHARD_INDEX"] = str(i)
            processes[i] = ProcessHandlerMixin(
                [app_path, "-unittest"],
                env=gtest_env,
                processOutputLine=[functools.partial(handle_line, i)],
                universal_newlines=True)
            processes[i].run()

        exit_code = 0
        for process in processes.values():
            status = process.wait()
            if status:
                exit_code = status

        # Clamp error code to 255 to prevent overflowing multiple of
        # 256 into 0
        if exit_code > 255:
            exit_code = 255

        return exit_code
Ejemplo n.º 4
0
 def __init__(self, cmd, queue, **kwargs):
     self.queue = queue
     kwargs.setdefault('processOutputLine', []).append(self.handle_output)
     ProcessHandlerMixin.__init__(self, cmd, **kwargs)
Ejemplo n.º 5
0
 def __init__(self, logfile, cmd, **kwargs):
     self.logfile = logfile
     kwargs.setdefault('processOutputLine', []).append(self.log_output)
     ProcessHandlerMixin.__init__(self, cmd, **kwargs)
Ejemplo n.º 6
0
 def __init__(self, logfile, cmd, **kwargs):
     self.logfile = logfile
     kwargs.setdefault('processOutputLine', []).append(self.log_output)
     ProcessHandlerMixin.__init__(self, cmd, **kwargs)
Ejemplo n.º 7
0
 def __init__(self, config, *args, **kwargs):
     self.config = config
     kwargs['processOutputLine'] = [self.process_line]
     ProcessHandlerMixin.__init__(self, *args, **kwargs)
Ejemplo n.º 8
0
 def run(self, *args, **kwargs):
     # protect against poor SIGINT handling. Handle it here instead
     # so we can kill the process without a cryptic traceback.
     orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
     ProcessHandlerMixin.run(self, *args, **kwargs)
     signal.signal(signal.SIGINT, orig)
Ejemplo n.º 9
0
 def __init__(self, config, *args, **kwargs):
     self.config = config
     kwargs['processOutputLine'] = [self.process_line]
     ProcessHandlerMixin.__init__(self, *args, **kwargs)
Ejemplo n.º 10
0
 def run(self, *args, **kwargs):
     # flake8 seems to handle SIGINT poorly. Handle it here instead
     # so we can kill the process without a cryptic traceback.
     orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
     ProcessHandlerMixin.run(self, *args, **kwargs)
     signal.signal(signal.SIGINT, orig)
Ejemplo n.º 11
0
 def run(self, *args, **kwargs):
     orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
     ProcessHandlerMixin.run(self, *args, **kwargs)
     signal.signal(signal.SIGINT, orig)
Ejemplo n.º 12
0
 def __init__(self, cmd, **kwargs):
     kwargs.setdefault('processOutputLine',
                       []).append(manager.processOutputLine)
     ProcessHandlerMixin.__init__(self, cmd, **kwargs)
Ejemplo n.º 13
0
 def run(self, *args, **kwargs):
     orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
     ProcessHandlerMixin.run(self, *args, **kwargs)
     signal.signal(signal.SIGINT, orig)
Ejemplo n.º 14
0
 def run(self, *args, **kwargs):
     # flake8 seems to handle SIGINT poorly. Handle it here instead
     # so we can kill the process without a cryptic traceback.
     orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
     ProcessHandlerMixin.run(self, *args, **kwargs)
     signal.signal(signal.SIGINT, orig)
Ejemplo n.º 15
0
 def __init__(self, cmd, **kwargs):
   kwargs.setdefault('processOutputLine', []).append(manager.processOutputLine)
   ProcessHandlerMixin.__init__(self, cmd, **kwargs)