def run_tests(self): """ Run the tests in a subprocess, record stdout & stderr on runpath. Optionally enforce a timeout and log timeout related messages in the given timeout log path. """ with self.result.report.logged_exceptions(), open( self.stderr, "w" ) as stderr, open(self.stdout, "w") as stdout: if not os.path.exists(self.cfg.driver): raise IOError( "No runnable found at {} for {}".format( self.cfg.driver, self ) ) # Need to use driver's absolute path if proc_cwd is specified, # otherwise won't be able to find the driver. if self.cfg.proc_cwd: self.cfg.driver = os.path.abspath(self.cfg.driver) test_cmd = self.test_command() self.result.report.logger.debug( "Running {} - Command: {}".format(self, test_cmd) ) if not test_cmd: raise ValueError( "Invalid test command generated for: {}".format(self) ) self._test_process = subprocess_popen( test_cmd, stderr=stderr, stdout=stdout, cwd=self.cfg.proc_cwd, env=self.get_proc_env(), ) if self.cfg.timeout: with open(self.timeout_log, "w") as timeout_log: enforce_timeout( process=self._test_process, timeout=self.cfg.timeout, output=timeout_log, callback=self.timeout_callback, ) self._test_process_retcode = self._test_process.wait() else: self._test_process_retcode = self._test_process.wait() self._test_has_run = True
def run_tests(self): """ Run the tests in a subprocess, record stdout & stderr on runpath. Optionally enforce a timeout and log timeout related messages in the given timeout log path. :return: """ with self.result.report.logged_exceptions(), \ open(self.stderr, 'w') as stderr, \ open(self.stdout, 'w') as stdout: test_cmd = self.test_command() self.result.report.logger.debug('Running {} - Command: {}'.format( self, test_cmd)) if not test_cmd: raise ValueError( 'Invalid test command generated for: {}'.format(self)) if not os.path.exists(self.cfg.driver): raise IOError('No runnable found at {} for {}'.format( self.cfg.driver, self)) self._test_process = subprocess_popen( self.test_command(), stderr=stderr, stdout=stdout, cwd=self.cfg.proc_cwd, env=self.cfg.proc_env, ) if self.cfg.timeout: with open(self.timeout_log, 'w') as timeout_log: enforce_timeout(process=self._test_process, timeout=self.cfg.timeout, output=timeout_log, callback=self.timeout_callback) self._test_process_retcode = self._test_process.wait() else: self._test_process_retcode = self._test_process.wait() self._test_has_run = True
def run_tests(self): """ Run the tests in a subprocess, record stdout & stderr on runpath. Optionally enforce a timeout and log timeout related messages in the given timeout log path. """ with self.result.report.logged_exceptions(), open( self.stderr, "w" ) as stderr, open(self.stdout, "w") as stdout: if not os.path.exists(self.cfg.binary): raise IOError( "No runnable found at {} for {}".format( self.cfg.binary, self ) ) test_cmd = self.test_command() self.result.report.logger.debug( "Running {} - Command: {}".format(self, test_cmd) ) if not test_cmd: raise ValueError( "Invalid test command generated for: {}".format(self) ) self._test_process = subprocess_popen( test_cmd, stderr=stderr, stdout=stdout, cwd=self.cfg.proc_cwd, env=self.get_proc_env(), ) if self.cfg.timeout: with open(self.timeout_log, "w") as timeout_log: timeout_checker = enforce_timeout( process=self._test_process, timeout=self.cfg.timeout, output=timeout_log, callback=self.timeout_callback, ) self._test_process_retcode = self._test_process.wait() timeout_checker.join() else: self._test_process_retcode = self._test_process.wait() self._test_has_run = True