def process_rspecs( self ): # # Look for RSpecs at the root of the view. Multiple RSpecs are # prohibited unless one of them ends up importing all of the others # (directly or indirectly). # # Collect all rspecs rspec_path_list = list() root_files = os.listdir( self.localPath ) rspec = None for f in root_files: root, ext = os.path.splitext( f ) if ext.lower() == '.rspec': rspec_path = os.path.join(self.getRoot(), f ) if rspec == None: rspec = RSpecFile( rspec_path, parent=None, view=self, wipe_cache=True) else: userErrorExit("Only one rspec is allowed at the root of the view.") if rspec == None: userErrorExit("No RSpec found in view") infoMessage("Using RSpec: '%s'"%(rspec.getFilename()), 2) self.setRSpec( rspec )
def process_rspecs( self ): # # Look for RSpecs at the root of the view. Multiple RSpecs are # prohibited unless one of them ends up importing all of the others # (directly or indirectly). # # Collect all rspecs rspec_path_list = list() root_files = os.listdir( self.localPath ) for f in root_files: root, ext = os.path.splitext( f ) if ext.lower() == '.rspec': rspec_path_list.append( os.path.join(self.getRoot(), f ) ) if len(rspec_path_list) != 0: infoMessage("RSpecs detected in view: \n %s"%("\n ".join(rspec_path_list)), 2) # Determine the import relationship between the RSpecs if len(rspec_path_list): # candidate_rspecs = list() for rspec_path in rspec_path_list: rspec = RSpecFile( rspec_path, parent=None, view=self ) remainder = False for potential_import in rspec_path_list: if potential_import == rspec_path: continue # skip checking if we import ourselves if potential_import not in rspec.getImportPaths( recursive=True ): remainder = True break # we found an RSpec not imported so move on to the next one # remainder is False if all other RSpecs could be found in the # import tree of 'rspec', or if 'rspec' is the only one present # in the view. if remainder == False: candidate_rspecs.append( rspec ) # We should have exactly ONE candidate rspec. If we have zero candidates, it # means no single rspec imports all the others. # If we have multiple candidates, it means more than one rspec imports all # the others. Both these cases are terminal errors since we have no logic # way of selecting one of the candidates. if len(candidate_rspecs) != 1: userErrorExit("RSpec selection is ambiguous. Only one RSpec is allowed in a view. If multiple RSpecs exist, at least one of them must directly or indirectly import the others") else: infoMessage("Using RSpec: '%s'"%(candidate_rspecs[0].getFilename()), 2) self.setRSpec( candidate_rspecs[0] ) else: infoMessage("No RSpec found in view", 2)