Runs a specified test inside a given container.

        Returns:
            the outcome of the test execution.
171568
def execute(self,
                container: Container,
                test: TestCase,
                verbose: bool = False
                ) -> TestOutcome:
        
        bug = self.__installation.bugs[container.bug]  # type: Bug
        response = self.command(container,
                                cmd=test.command,
                                context=test.context,
                                stderr=True,
                                time_limit=test.time_limit,
                                kill_after=test.kill_after,
                                verbose=verbose)
        passed = test.oracle.check(response)
        return TestOutcome(response, passed)
57766
def execute(self):
        

        with self._lock_c:
            self.count = 0
            self.numtasks = 0
            self.taskset = []
            self.results = {}
            self.totaltime = time.time()
            # Start all tasks
            for task in self.taskseq:
                self.taskset.append(task)
                self.numtasks += 1
                task.init_and_start(self)

        num_tasks = self.getNumTasks()
        # Wait on each task to clean up results
        while num_tasks > 0:

            self.check_state()

            for i in range(num_tasks):
                try:
                    try:
                        task = self.getTask(i)
                    except IndexError:
                        # A task got deleted from the set.  Jump back out
                        # to outer loop and repoll the number of tasks
                        break

                    #self.logger.debug("waiting on %s" % task)
                    res = task.wait(timeout=self.idletime)

                    #self.logger.debug("finished: %s" % task)
                    self.child_done(res, task)

                except TaskTimeout:
                    continue

                except Exception as e:
                    #self.logger.warning("Subtask propagated exception: %s" % str(e))
                    self.child_done(e, task)
                    continue

            # wait a bit and try again
            #self.ev_quit.wait(self.idletime)

            # re-get number of tasks, in case some were added or deleted
            num_tasks = self.getNumTasks()

        # Scan results for errors (exceptions) and raise the first one we find
        for key in self.results.keys():
            value = self.results[key]
            if isinstance(value, Exception):
                (count, task) = key
                self.logger.error("Child task %s terminated with exception: %s" % (
                    task.tag, str(value)))
                raise value

        # Return value of last child to complete
        return value
1109593
def _run_suite(self, test_suite):
        
        tests_results = []

        for testcase in test_suite:
            testcase_name = testcase.config.get("name")
            logger.log_info("Start to run testcase: {}".format(testcase_name))

            result = self.unittest_runner.run(testcase)
            tests_results.append((testcase, result))

        return tests_results
945408
def run(self, data):
        
        result_type = namedtuple('Result', 'code messages')

        if self.passes is True:
            result = result_type(Checker.Code.PASSED, '')
        elif self.passes is False:
            if self.allow_failure:
                result = result_type(Checker.Code.IGNORED, '')
            else:
                result = result_type(Checker.Code.FAILED, '')
        else:
            try:
                result = self.check(data, **self.arguments)
                messages = ''
                if isinstance(result, tuple):
                    result, messages = result

                if result not in Checker.Code:
                    result = Checker.Code.PASSED if bool(result) else Checker.Code.FAILED

                if result == Checker.Code.FAILED and self.allow_failure:
                    result = Checker.Code.IGNORED

                result = result_type(result, messages)
            except NotImplementedError:
                result = result_type(Checker.Code.NOT_IMPLEMENTED, '')
        self.result = result
328287
def run():
    """"""

    command = sys.argv[1].strip().lower()
    print('[COMMAND]:', command)

    if command == 'test':
        return run_test()
    elif command == 'build':
        return run_build()
    elif command == 'up':
        return run_container()
    elif command == 'serve':
        import cauldron
        cauldron.run_server(port=5010, public=True)
825301
def run(self, test=False):
        ''''''
        self._request = self._parse_request()
        log.debug('Handling incoming request for %s', self.request.path)
        items = self._dispatch(self.request.path)

        # Close any open storages which will persist them to disk
        if hasattr(self, '_unsynced_storages'):
            for storage in self._unsynced_storages.values():
                log.debug('Saving a %s storage to disk at "%s"',
                          storage.file_format, storage.filename)
                storage.close()

        return items
477252
def run(self):
        

        executed_tests = []
        try:

            active_thread = 0
            start_thread = True
            current_index = 0
            active_thread_by_browser_id = {}

            test_index_by_browser_id = {}
            for browser_id in self.browsers_id:
                test_index_by_browser_id[browser_id] = 0

            self.kill_test_batch_if_necessary()

            while active_thread or start_thread:
                start_thread = False

                self.kill_test_batch_if_necessary()

                for browser_id in self.browsers_id:

                    if active_thread_by_browser_id.get(browser_id) is None:
                        active_thread_by_browser_id[browser_id] = 0
                    else:
                        current_active_thread = 0
                        for thread in threading.enumerate():

                            # Make sure that the thread is TestThread
                            if hasattr(thread, 'test'):
                                if thread.test._browser_config.browser_id == browser_id:  # noqa
                                    current_active_thread += 1

                        active_thread_by_browser_id[browser_id] = current_active_thread  # noqa

                    for j in range(0, len(self.instances[browser_id]) - active_thread_by_browser_id[browser_id]):  # noqa

                        self.kill_test_batch_if_necessary()

                        if test_index_by_browser_id[browser_id] < len(self.tests):  # noqa
                            current_index += 1

                            test = self.tests[test_index_by_browser_id[browser_id]]  # noqa

                            test_index_by_browser_id[browser_id] += 1

                            test_ = test.Test(
                                runner=self,
                                test_batch_id=self.test_batch_id,
                                browser_config=self.browser_configs[browser_id],  # noqa
                                name=test.Test.name,
                                index=test_index_by_browser_id[browser_id]
                            )
                            test_.pdriver.embed_disabled = True

                            thread = TestThread(test_)
                            thread.start()

                            executed_tests.append(test_)

                active_thread = len([tn for tn in threading.enumerate() if type(tn) != threading._MainThread and hasattr(tn, 'test')])  # noqa
                # self.info_log("active_thread=%s" % active_thread)
                if active_thread:
                    try:
                        active_thread_test_number = len([tn for tn in threading.enumerate() if type(tn) != threading._MainThread and hasattr(tn, 'test')])  # noqa
                        self.info_log("Active thread number: %s" % active_thread_test_number)  # noqa
                        self.info_log("Active thread name: %s" % (', '.join([  # noqa
                                "%s-%s" % (
                                    th.test._browser_config.browser_id,
                                    th.test._name
                                ) for th in threading.enumerate() if type(th) != threading._MainThread and hasattr(th, 'test')  # noqa
                            ])
                        ))
                    except Exception as e:
                        self.error_log("print active exception: %s" % str(e))

                # TIMEOUT
                now = utcnow()
                if (self.starting_timestamp - now).total_seconds() >\
                        BROME_CONFIG['grid_runner']['max_running_time']:

                    self.error_log("max_running_time reached... terminating!")
                    raise TestRunnerKilledException()

                self.kill_test_batch_if_necessary()

                sleep(10)

        except TestRunnerKilledException:
            pass

        except Exception:
            tb = traceback.format_exc()
            self.error_log("Run exception: %s" % str(tb))

        self.set_ending_timestamp()

        self.print_test_summary(executed_tests)
365210
def run(self):
        ''''''
        with spawn_output_reader() as (stdout_capture, stdout_thread):
            with spawn_output_reader() as (stderr_capture, stderr_thread):
                context = starter_iocontext(stdout_capture, stderr_capture)
                status = self._exec(context)
        stdout_bytes = stdout_thread.join()
        stderr_bytes = stderr_thread.join()
        result = Result(status.code, stdout_bytes, stderr_bytes)
        if is_checked_error(status):
            raise StatusError(result, self)
        return result
80714
def report(test)
      case test.result
      when :success
        if @type == :test
          print_test_success(test)
        else
          print_generate_success(test)
        end
        @success += 1

      when :skipped
        if @type == :test
          print_test_skipped(test)
        else
          print_generate_skipped(test)
        end
        @skipped += 1

      # Generate can't fail directly
      when :failed
        print_test_failed(test)
        @failed += 1

      when :timedout
        if @type == :test
          print_test_timeout(test)
        else
          print_generate_timeout(test)
        end
        @failed += 1
      end
    end
392916
def run_in_container(command, container_dir):
    
    container_p = local.path(container_dir)
    with local.cwd(container_p):
        uchrt = uchroot.with_mounts()
        uchrt = uchrt["-E", "-A", "-u", "0", "-g", "0", "-C", "-w", "/", "-r",
                      container_p]
        uchrt = uchrt["--"]

        cmd_path = container_p / command[0].lstrip('/')
        if not cmd_path.exists():
            LOG.error("The command does not exist inside the container! %s",
                      cmd_path)
            return

        cmd = uchrt[command]
        return cmd & FG
39584
def run(self):
        

        async def run_command():
            try:
                self.result = self.command(
                    context=self.context,
                    **self.kwargs
                )
            except Exception as error:
                self.exception = error
                print(error)
                import traceback
                traceback.print_exc()
                import sys
                self.context.response.fail(
                    code='COMMAND_EXECUTION_ERROR',
                    message='Failed to execute command due to internal error',
                    error=error
                ).console(
                    whitespace=1
                )

        self._has_started = True
        self._loop = asyncio.new_event_loop()
        self._loop.run_until_complete(run_command())
        self._loop.close()
        self._loop = None
        self.completed_at = datetime.utcnow()
838750
def extract_coverage(self, container: Container) -> FileLineSet:
        
        uid = container.uid
        r = self.__api.post('containers/{}/read-coverage'.format(uid))
        if r.status_code == 200:
            return FileLineSet.from_dict(r.json())
        self.__api.handle_erroneous_response(r)
960740
def run(self):
        """"""
        if self.auto_clear:
            os.system('cls' if os.name == 'nt' else 'auto_clear')
        else:
            print
        print 'Running unit tests...'
        if self.auto_clear:
            print
        subprocess.call('nosetests', cwd=self.directory)
731796
private static void executeInPlayContext( Runner runner, RunNotifier notifier )
        throws TestSetFailedException
    {
        try
        {
            Invoker.invokeInThread( new TestInvocation( runner, notifier ) );
        }
        catch ( Throwable e )
        {
            throw new TestSetFailedException( e );
        }
    }
1025898
def run(self):
        # type: () -> bool
        
        with util.timed_block() as t:
            files = self._collect_files()

        log.info("Collected <33>{} <32>files in <33>{}s".format(
            len(files), t.elapsed_s
        ))
        if self.verbose:
            for p in files:
                log.info("  <0>{}", p)

        # No files to lint - return success if empty runs are allowed.
        if not files:
            return self.allow_empty

        with util.timed_block() as t:
            results = self._run_checks(files)

        log.info("Code checked in <33>{}s", t.elapsed_s)

        success = True
        for name, retcodes in results.items():
            if any(x != 0 for x in retcodes):
                success = False
                log.err("<35>{} <31>failed with: <33>{}".format(
                    name, retcodes
                ))

        return success
1101523
def runContainer(image, **kwargs):
    '''
    '''
    container = None
    try:
        container = client.containers.run(image, **kwargs)
        if "name" in kwargs.keys():
          print("Container", kwargs["name"], "is now running.")
    except ContainerError as exc:
        eprint("Failed to run container")
        raise exc
    except ImageNotFound as exc:
        eprint("Failed to find image to run as a docker container")
        raise exc
    except APIError as exc:
        eprint("Unhandled error")
        raise exc

    return container
770390
def _run(name,
         cmd,
         output=None,
         no_start=False,
         stdin=None,
         python_shell=True,
         preserve_state=False,
         output_loglevel='debug',
         ignore_retcode=False,
         use_vt=False,
         keep_env=None):
    '''
    
    '''
    orig_state = state(name)
    exc = None
    try:
        ret = __salt__['container_resource.run'](
            name,
            cmd,
            container_type=__virtualname__,
            exec_driver=EXEC_DRIVER,
            output=output,
            no_start=no_start,
            stdin=stdin,
            python_shell=python_shell,
            output_loglevel=output_loglevel,
            ignore_retcode=ignore_retcode,
            use_vt=use_vt,
            keep_env=keep_env)
    except Exception:
        raise
    finally:
        # Make sure we stop the container if necessary, even if an exception
        # was raised.
        if preserve_state \
                and orig_state == 'stopped' \
                and state(name) != 'stopped':
            stop(name)

    if output in (None, 'all'):
        return ret
    else:
        return ret[output]