def test_start(self): start(self.path, self.args, self.all_repo_addons, self.config) records = [Record.__str__(r) for r in ReportManager.getEnabledReporters()[0].reports] # Comparing the whitelist with the list of output we get from addon-checker tool for white_str in self.whitelist: for value in records: if white_str.lower() == value.lower(): break else: flag = False else: flag = True self.assertTrue(flag)
def check_repo(repo_path, args, all_repo_addons, config): """Perform all the check on a complete repository :repo_path: Path of the repo that is to be tested :args: argparse object :all_repo_addons: a nested list having information about all the repo addons :config: Config object """ repo_report = Report(repo_path) repo_report.add(Record(INFORMATION, "Checking repository %s" % repo_path)) toplevel_folders = sorted(next(os.walk(repo_path))[1]) for addon_folder in toplevel_folders: if addon_folder[0] != '.': addon_path = os.path.join(repo_path, addon_folder) try: addon_report = check_addon.start(addon_path, args, all_repo_addons, config) repo_report.add(addon_report) except Exception as e: # pylint: disable=broad-except repo_report.add( Record(PROBLEM, "Something went wrong. Please see: %s" % e)) return repo_report
def check_artifact(artifact_path, args, all_repo_addons): """ Check given artifact and return its report. The artifact can be either an add-on or a repository. :param artifact_path: the path of add-on or repo :param args: argparse object :return: report """ logger = logging.getLogger(__package__) logger.info("Downloading all repo addon list") logger.info("Download completed") artifact_path = os.path.abspath(artifact_path) config = Config(artifact_path, args) ConfigManager.process_config(config) if os.path.isfile(os.path.join(artifact_path, "addon.xml")): return check_addon.start(artifact_path, args, all_repo_addons, config) else: return check_repo(artifact_path, args, all_repo_addons, config)
def check_repo(repo_path, branch_name, all_repo_addons, pr, config): repo_report = Report(repo_path) repo_report.add(Record(INFORMATION, "Checking repository %s" % repo_path)) toplevel_folders = sorted(next(os.walk(repo_path))[1]) for addon_folder in toplevel_folders: if addon_folder[0] != '.': addon_path = os.path.join(repo_path, addon_folder) try: addon_report = check_addon.start(addon_path, branch_name, all_repo_addons, pr, config) repo_report.add(addon_report) except Exception as e: repo_report.add( Record(PROBLEM, "Something went wrong. Please see: %s" % e)) return repo_report
def check_repo(config, repo_path, parameters): repo_report = Report(repo_path) repo_report.add(Record(INFORMATION, "Checking repository %s" % repo_path)) if len(parameters) == 0: toplevel_folders = sorted(next(os.walk(repo_path))[1]) else: toplevel_folders = sorted(parameters) for addon_folder in toplevel_folders: if addon_folder[0] != '.': repo_report.add( Record(INFORMATION, "Checking add-on %s" % addon_folder)) addon_path = os.path.join(repo_path, addon_folder) addon_report = check_addon.start(addon_path, config) repo_report.add(addon_report) if repo_report.problem_count > 0: repo_report.add( Record( PROBLEM, "We found %s problems and %s warnings, please check the logfile." % (repo_report.problem_count, repo_report.warning_count))) elif repo_report.warning_count > 0: repo_report.add( Record( WARNING, "We found %s problems and %s warnings, please check the logfile." % (repo_report.problem_count, repo_report.warning_count))) else: repo_report.add( Record( INFORMATION, "We found no problems and no warnings, please enjoy your day.") ) ReportManager.report(repo_report)