def get_control_file_path(self, test_name): """ Given the name of a control file, return its path. Searches through previously-compiled list in |self._files| for a test named |test_name| and returns the contents of the control file for that test if it is found. @param test_name: the name of the test whose control file is desired. @return control file path @throws ControlFileNotFound if the file cannot be retrieved. """ if not self._files and not self.get_control_file_list(): raise error.ControlFileNotFound('No control files found.') if 'control' not in test_name: regexp = re.compile(os.path.join(test_name, 'control$')) else: regexp = re.compile(test_name + '$') candidates = filter(regexp.search, self._files) if not candidates: raise error.ControlFileNotFound('No control file for ' + test_name) if len(candidates) > 1: raise error.ControlFileNotFound(test_name + ' is not unique.') return candidates[0]
def get_control_file_contents(self, test_path): """ Get the contents of the control file at |test_path|. @return The contents of the aforementioned file. @throws ControlFileNotFound if the file cannot be retrieved. """ try: return utils.read_file(test_path) except EnvironmentError as (errno, strerror): msg = "Can't retrieve {0}: {1} ({2})".format( test_path, strerror, errno) raise error.ControlFileNotFound(msg)
def get_control_file_contents(self, test_path): """ Return the contents of |test_path| from |self._dev_server|. Get the contents of the control file at |test_path| for |self._build| on |self._dev_server|. @return The contents of |test_path|. None on failure. @throws ControlFileNotFound if the file cannot be retrieved. """ try: return self._dev_server.get_control_file(self._build, test_path) except dev_server.DevServerException as e: raise error.ControlFileNotFound(e)
def _SetupScheduleSuiteMocks(self, mock_bug_id): """Setup mocks needed for SuiteSchedulerBug testing. @param mock_bug_id: An integer representing a bug id that should be returned by Reporter._create_bug_report None if _create_bug_report is supposed to fail. """ self.mox.StubOutWithMock(reporting.Reporter, '__init__') self.mox.StubOutWithMock(reporting.Reporter, '_create_bug_report') self.mox.StubOutWithMock(reporting.Reporter, '_check_tracker') self.mox.StubOutWithMock(reporting.Reporter, '_find_issue_by_marker') self.mox.StubOutWithMock(site_utils, 'get_sheriffs') self.scheduler._file_bug = True # Lab is UP! self._SetupLabStatus(self._BUILD) # A similar suite has not already been scheduled. self.afe.get_jobs(name__istartswith=self._BUILD, name__iendswith='control.' + self._SUITE, created_on__gte=mox.IgnoreArg(), min_rpc_timeout=mox.IgnoreArg()).AndReturn([]) message = 'Control file not found.' exception = error.ControlFileNotFound(message) site_utils.get_sheriffs(lab_only=True).AndReturn( ['deputy1', 'deputy2']) self.afe.run('create_suite_job', name=self._SUITE, board=self._BOARD, builds=self._BUILDS, check_hosts=False, pool=self._POOL, num=self._NUM, priority=self._PRIORITY, test_source_build=None, timeout=self._TIMEOUT, max_runtime_mins=self._TIMEOUT_MINS, timeout_mins=self._TIMEOUT_MINS, file_bugs=False, wait_for_results=False, job_retry=False, delay_minutes=0, run_prod_code=False, min_rpc_timeout=mox.IgnoreArg()).AndRaise(exception) reporting.Reporter.__init__() reporting.Reporter._check_tracker().AndReturn(True) (reporting.Reporter._find_issue_by_marker( mox.IgnoreArg()).AndReturn(None)) reporting.Reporter._create_bug_report(mox.IgnoreArg(), {}, []).AndReturn(mock_bug_id)
def fail(): raise error.ControlFileNotFound()