def run_tests(self, tests): start_time = time.time() self._initialize_test_run(tests) if self.marionette is None: self.marionette = self.driverclass(**self._build_kwargs()) self.logger.info("Profile path is %s" % self.marionette.profile_path) if len(self.fixture_servers) == 0 or \ any(not server.is_alive for _, server in self.fixture_servers): self.logger.info("Starting fixture servers") self.fixture_servers = self.start_fixture_servers() for url in iter_url(self.fixture_servers): self.logger.info("Fixture server listening on %s" % url) # backwards compatibility self.marionette.baseurl = serve.where_is("/") self._add_tests(tests) device_info = None if self.marionette.instance and self.emulator: try: device_info = self.marionette.instance.runner.device.dm.getInfo() except Exception: self.logger.warning('Could not get device info', exc_info=True) appinfo_e10s = self.appinfo.get('browserTabsRemoteAutostart', False) self.logger.info("e10s is {}".format("enabled" if appinfo_e10s else "disabled")) if self.e10s != appinfo_e10s: message_e10s = ("BaseMarionetteTestRunner configuration (self.e10s) does " "not match browser appinfo") self.cleanup() raise AssertionError(message_e10s) self.logger.suite_start(self.tests, version_info=self.version_info, device_info=device_info) self._log_skipped_tests() interrupted = None try: counter = self.repeat while counter >= 0: round_num = self.repeat - counter if round_num > 0: self.logger.info('\nREPEAT {}\n-------'.format(round_num)) self.run_test_sets() counter -= 1 except KeyboardInterrupt: # in case of KeyboardInterrupt during the test execution # we want to display current test results. # so we keep the exception to raise it later. interrupted = sys.exc_info() except: # For any other exception we return immediately and have to # cleanup running processes self.cleanup() raise try: self._print_summary(tests) self.record_crash() self.elapsedtime = time.time() - start_time for run_tests in self.mixin_run_tests: run_tests(tests) if self.shuffle: self.logger.info("Using shuffle seed: %d" % self.shuffle_seed) self.logger.suite_end() except: # raise only the exception if we were not interrupted if not interrupted: raise finally: self.cleanup() # reraise previous interruption now if interrupted: raise interrupted[0], interrupted[1], interrupted[2]
def run_tests(self, tests): start_time = time.time() self._initialize_test_run(tests) if self.marionette is None: self.marionette = self.driverclass(**self._build_kwargs()) self.logger.info("Profile path is %s" % self.marionette.profile_path) if len(self.fixture_servers) == 0 or \ any(not server.is_alive for _, server in self.fixture_servers): self.logger.info("Starting fixture servers") self.fixture_servers = self.start_fixture_servers() for url in iter_url(self.fixture_servers): self.logger.info("Fixture server listening on %s" % url) # backwards compatibility self.marionette.baseurl = serve.where_is("/") self._add_tests(tests) device_info = None if self.marionette.instance and self.emulator: try: device_info = self.marionette.instance.runner.device.dm.getInfo( ) except Exception: self.logger.warning('Could not get device info', exc_info=True) self.marionette.start_session() self.logger.info( "e10s is {}".format("enabled" if self.is_e10s else "disabled")) if self.e10s != self.is_e10s: self.cleanup() raise AssertionError( "BaseMarionetteTestRunner configuration (self.e10s) " "does not match browser appinfo (self.is_e10s)") self.marionette.delete_session() tests_by_group = defaultdict(list) for test in self.tests: tests_by_group[test['group']].append(test['filepath']) self.logger.suite_start(tests_by_group, version_info=self.version_info, device_info=device_info) self._log_skipped_tests() interrupted = None try: repeat_index = 0 while repeat_index <= self.repeat: if repeat_index > 0: self.logger.info( "\nREPEAT {}\n-------".format(repeat_index)) self.run_test_sets() if self.run_until_failure and self.failed > 0: break repeat_index += 1 except KeyboardInterrupt: # in case of KeyboardInterrupt during the test execution # we want to display current test results. # so we keep the exception to raise it later. interrupted = sys.exc_info() except: # For any other exception we return immediately and have to # cleanup running processes self.cleanup() raise try: self._print_summary(tests) self.record_crash() self.elapsedtime = time.time() - start_time for run_tests in self.mixin_run_tests: run_tests(tests) if self.shuffle: self.logger.info("Using shuffle seed: %d" % self.shuffle_seed) self.logger.suite_end() except: # raise only the exception if we were not interrupted if not interrupted: raise finally: self.cleanup() # reraise previous interruption now if interrupted: raise interrupted[0], interrupted[1], interrupted[2]