def match_prod_file(self, root, directories, filename): """ Searches for a file starting with the prefix and ending with one of the test suffixes. Example: Given a test file of: XyzWithSomeContextIntSpec returns a prod file of: Xyz """ scoggle = self.param.scoggle prefix = self.param.prefix suffixes = self.param.suffixes logger = self.param.logger prod_file = scoggle.remove_largest_suffix_from_prefix(prefix, scoggle.get_files_without_extension(suffixes)) name_only = scoggle.get_file_without_extension(filename) logger.debug("prod_file: " + prod_file + ",name_only: " + name_only) return prod_file.startswith(name_only) and filename.endswith(".scala")
def match_prod_file(self, root, directories, filename): """ Searches for any file that contains the prefix and ends with the longest test suffix. Example: Given a test file of: AnXyzWithSomeContextSpec returns matching prod file: Xyz """ scoggle = self.param.scoggle prefix = self.param.prefix suffixes = self.param.suffixes logger = self.param.logger prod_file = scoggle.remove_largest_suffix_from_prefix(prefix, scoggle.get_files_without_extension(suffixes)) filename_only = scoggle.get_file_without_extension(filename) logger.debug("WildcardPrefixWildcardSuffixMatcher: possible_prod_file: " + prod_file + ",filename_only: " + filename_only) possible_matching_files = scoggle.find_matching_words(prod_file) logger.debug("WildcardPrefixWildcardSuffixMatcher: possible_matches: " + str(possible_matching_files)) filter = [mf for mf in possible_matching_files if mf.startswith(filename_only) and filename.endswith(".scala")] logger.debug("WildcardPrefixWildcardSuffixMatcher: matches: " + str(filter)) return len(filter) > 0