8 from roscompile
import get_functions
14 matches, missed_deletes, missed_generations = pkg_in.compare_filesets(pkg_out)
18 for fn
in missed_deletes:
20 click.secho(
'Should have deleted %s' % fn, fg=
'yellow')
22 for fn
in missed_generations:
24 click.secho(
'Failed to generate %s' % fn, fg=
'yellow')
26 for filename
in matches:
27 generated_contents = pkg_in.get_contents(filename).replace(
'\r\n',
'\n')
28 canonical_contents = pkg_out.get_contents(filename).replace(
'\r\n',
'\n')
29 if generated_contents.strip() == canonical_contents.strip():
34 if gen_line == can_line:
35 click.echo(repr(gen_line))
37 click.secho(repr(gen_line) +
' should be ' + repr(can_line), fg=
'yellow')
41 if __name__ ==
'__main__':
42 parser = argparse.ArgumentParser()
43 parser.add_argument(
'zipfile')
44 parser.add_argument(
'-f',
'--fail_once', action=
'store_true')
45 parser.add_argument(
'-l',
'--last', action=
'store_true')
46 args = parser.parse_args()
52 for test_config
in config:
53 if args.last
and test_config != config[-1]:
56 with cases[test_config[
'in']]
as pkg_in:
59 if test_config[
'in'] == test_config[
'out']:
60 pkg_out = pkg_in.copy()
62 pkg_out = cases[test_config[
'out']]
64 click.secho(
'{:25} >> {:25} {}'.format(test_config[
'in'], test_config[
'out'],
65 ','.join(test_config[
'functions'])),
66 bold=
True, fg=
'white')
68 if 'subpkg' in test_config:
69 root = os.path.join(root, test_config[
'subpkg'])
71 local_config = test_config.get(
'config', {})
72 for function_name
in test_config[
'functions']:
73 fne = roscompile_functions[function_name]
74 if 'config' in inspect.getargspec(fne).args:
75 fne(pp, config=local_config)
80 click.secho(
' SUCCESS', fg=
'green')
83 click.secho(
' FAIL', fg=
'red')
86 except Exception
as e:
87 click.secho(
' EXCEPTION ' + str(e), fg=
'red')
93 click.secho(
'{}/{}'.format(successes, total), bold=
True, fg=
'white')