3 from zipfile_interface
import get_test_cases
5 from roscompile
import get_functions
12 matches, missed_deletes, missed_generations = pkg_in.compare_filesets(pkg_out)
16 for fn
in missed_deletes:
18 click.secho(
'Should have deleted %s' % fn, fg=
'yellow')
20 for fn
in missed_generations:
22 click.secho(
'Failed to generate %s' % fn, fg=
'yellow')
24 for filename
in matches:
25 generated_contents = pkg_in.get_contents(filename).replace(
'\r\n',
'\n')
26 canonical_contents = pkg_out.get_contents(filename).replace(
'\r\n',
'\n')
27 if generated_contents.strip() == canonical_contents.strip():
32 if gen_line == can_line:
33 click.echo(repr(gen_line))
35 click.secho(repr(gen_line) +
' should be ' + repr(can_line), fg=
'yellow')
39 if __name__ ==
'__main__':
40 parser = argparse.ArgumentParser()
41 parser.add_argument(
'zipfile')
42 parser.add_argument(
'-f',
'--fail_once', action=
'store_true')
43 parser.add_argument(
'-l',
'--last', action=
'store_true')
44 args = parser.parse_args()
50 for test_config
in config:
51 if args.last
and test_config != config[-1]:
54 with cases[test_config[
'in']]
as pkg_in:
57 if test_config[
'in'] == test_config[
'out']:
58 pkg_out = pkg_in.copy()
60 pkg_out = cases[test_config[
'out']]
62 click.secho(
'{:25} >> {:25} {}'.format(test_config[
'in'], test_config[
'out'],
63 ','.join(test_config[
'functions'])),
64 bold=
True, fg=
'white')
66 if 'subpkg' in test_config:
67 root = os.path.join(root, test_config[
'subpkg'])
69 local_config = test_config.get(
'config', {})
70 for function_name
in test_config[
'functions']:
71 fne = roscompile_functions[function_name]
72 if 'config' in inspect.getargspec(fne).args:
73 fne(pp, config=local_config)
78 click.secho(
' SUCCESS', fg=
'green')
81 click.secho(
' FAIL', fg=
'red')
84 except Exception
as e:
85 click.secho(
' EXCEPTION ' + str(e), fg=
'red')
91 click.secho(
'{}/{}'.format(successes, total), bold=
True, fg=
'white')
def prepare_diff_lines(string_a, string_b)
def compare(pkg_in, pkg_out, debug=True)
def get_test_cases(zip_filename)