def test_find_shell_scripts(self): self.build_tree([ "fixers/", "fixers/anotherdir/", "fixers/i-fix-a-tag.sh", "fixers/i-fix-another-tag.py", "fixers/.hidden", "fixers/backup-file.sh~", "fixers/no-extension", ]) self.build_tree_contents([( "fixers/index.desc", """\ - script: foo.sh lintian-tags: - i-fix-a-tag - script: bar.sh lintian-tags: - i-fix-another-tag - no-extension """, )]) self.assertEqual( [["i-fix-a-tag"], ["i-fix-another-tag", "no-extension"]], [ fixer.lintian_tags for fixer in available_lintian_fixers("fixers") ], )
def test_suite(): suite = unittest.TestSuite() fixers = available_lintian_fixers() for fixer in fixers: for test_case in iter_test_cases(fixer): suite.addTest(test_case) suite.addTest(SaneFixerTests(fixer)) return suite
def __init__( self, names=None, exclude=None, propose_addon_only=None, compat_release=None, allow_reformatting=None, minimum_certainty=None, tags=None, opinionated=False, trust_package=False, diligence=0, ): self.fixers = get_fixers( available_lintian_fixers(), names=names, tags=tags, exclude=exclude ) self.propose_addon_only = propose_addon_only or [] self.compat_release = compat_release self.allow_reformatting = allow_reformatting self.minimum_certainty = minimum_certainty self.opinionated = opinionated self.trust_package = trust_package self.diligence = diligence
def main(args): import distro_info import socket import subprocess import silver_platter # noqa: F401 from . import ( propose_or_push, BuildFailedError, MissingUpstreamTarball, NoSuchPackage, ) from breezy import ( errors, ) from breezy.trace import note from breezy.plugins.propose.propose import ( NoSuchProject, UnsupportedHoster, ) possible_transports = [] possible_hosters = [] fixer_scripts = {} for fixer in available_lintian_fixers(): for tag in fixer.lintian_tags: fixer_scripts[tag] = fixer available_fixers = set(fixer_scripts) if args.fixers: available_fixers = available_fixers.intersection(set(args.fixers)) debian_info = distro_info.DebianDistroInfo() for pkg in args.packages: if args.pre_check: def pre_check(local_tree): try: subprocess.check_call(args.pre_check, shell=True, cwd=local_tree.basedir) except subprocess.CalledProcessError: note('%r: pre-check failed, skipping', pkg) return False return True else: pre_check = None if args.post_check: def post_check(local_tree, since_revid): try: subprocess.check_call(args.post_check, shell=True, cwd=local_tree.basedir, env={'SINCE_REVID': since_revid}) except subprocess.CalledProcessError: note('%r: post-check failed, skipping', pkg) return False return True else: post_check = None note('Processing: %s', pkg) try: main_branch = open_packaging_branch( pkg, possible_transports=possible_transports) except NoSuchPackage: note('%s: no such package', pkg) except socket.error: note('%s: ignoring, socket error', pkg) except errors.NotBranchError as e: note('%s: Branch does not exist: %s', pkg, e) except errors.UnsupportedProtocol: note('%s: Branch available over unsupported protocol', pkg) except errors.ConnectionError as e: note('%s: %s', pkg, e) except errors.PermissionDenied as e: note('%s: %s', pkg, e) except errors.InvalidHttpResponse as e: note('%s: %s', pkg, e) except errors.TransportError as e: note('%s: %s', pkg, e) else: # If it's unknown which fixers are relevant, just try all of them. if args.fixers: fixers = args.fixers else: fixers = available_fixers branch_changer = LintianFixer( pkg, fixers=[fixer_scripts[fixer] for fixer in fixers], update_changelog=args.update_changelog, compat_release=debian_info.stable(), build_verify=args.build_verify, pre_check=pre_check, post_check=post_check, propose_addon_only=args.propose_addon_only, committer=args.committer) try: result = propose_or_push( main_branch, "lintian-fixes", branch_changer, args.mode, possible_transports=possible_transports, possible_hosters=possible_hosters, refresh=args.refresh, dry_run=args.dry_run) except UnsupportedHoster: note('%s: Hoster unsupported', pkg) continue except NoSuchProject as e: note('%s: project %s was not found', pkg, e.project) continue except BuildFailedError: note('%s: build failed', pkg) continue except MissingUpstreamTarball: note('%s: unable to find upstream source', pkg) continue except errors.PermissionDenied as e: note('%s: %s', pkg, e) continue except PostCheckFailed as e: note('%s: %s', pkg, e) continue else: if result.merge_proposal: tags = set() for brush_result, unused_summary in branch_changer.applied: tags.update(brush_result.fixed_lintian_tags) if result.is_new: note('%s: Proposed fixes %r: %s', pkg, tags, result.merge_proposal.url) elif tags: note('%s: Updated proposal %s with fixes %r', pkg, result.merge_proposal.url, tags) else: note('%s: No new fixes for proposal %s', pkg, result.merge_proposal.url) if args.diff: result.show_base_diff(sys.stdout.buffer)
if __name__ == "__main__": import argparse import sys parser = argparse.ArgumentParser() parser.add_argument( "--fixer", type=str, default=None, action="append", help="Fixer for which to run tests.", ) parser.add_argument("--exclude", type=str, action="append", help="Exclude a fixer.") args = parser.parse_args() fixers = list(available_lintian_fixers()) if args.fixer: try: fixers = select_fixers(fixers, args.fixer, args.exclude) except KeyError as e: print("Selected fixer %s does not exist." % (e.args[0]), file=sys.stderr) sys.exit(0) suite = unittest.TestSuite() for fixer in fixers: for test_case in iter_test_cases(fixer): suite.addTest(test_case) runner = unittest.TextTestRunner() runner.run(suite)
import subprocess import sys from lintian_brush import available_lintian_fixers from ruamel.yaml import YAML KNOWN_KEYS = ['tag', 'status', 'difficulty', 'comment'] all_tags = set([ tag.decode() for tag in subprocess.check_output( ['lintian-explain-tags', '--list-tags']).splitlines() ]) supported_tags = set() for fixer in available_lintian_fixers(): supported_tags.update(fixer.lintian_tags) yaml = YAML() with open('tag-status.yaml', 'r') as f: tag_status = yaml.load(f) per_tag_status = {} for entry in tag_status or []: per_tag_status[entry['tag']] = entry extra_keys = set(entry.keys()) - set(KNOWN_KEYS) assert not extra_keys, 'Unknown keys: %r' % extra_keys for tag in supported_tags: existing = per_tag_status.get(tag) if existing and existing.get('status') != 'implemented':
#!/usr/bin/python3 from lintian_brush import available_lintian_fixers import re with open('README.md', 'r') as f: contents = f.read() fixers = available_lintian_fixers() tags = set() for fixer in fixers: tags.update(fixer.lintian_tags) replacement_text = ''.join(['* %s\n' % tag for tag in sorted(tags)]) with open('README.md', 'w') as f: # TODO(jelmer): Use better sentinels, just in case somebody changes # the current ones? f.write( re.sub(r'(subset of the issues:\n\n).*(\n\.\. _writing-fixers:\n)', '\\1' + replacement_text + '\\2', contents, flags=re.MULTILINE | re.DOTALL))