3 from zipfile_interface
import get_test_cases
5 from roscompile
import get_functions
9 def compare(pkg_in, pkg_out, debug=True):
10 matches, missed_deletes, missed_generations = pkg_in.compare_filesets(pkg_out)
14 for fn
in missed_deletes:
16 print(
'Should have deleted %s' % fn)
18 for fn
in missed_generations:
20 print(
'Failed to generate %s' % fn)
22 for filename
in matches:
23 generated_contents = pkg_in.get_contents(filename)
24 canonical_contents = pkg_out.get_contents(filename)
25 if generated_contents.strip() == canonical_contents.strip():
29 A = generated_contents.split(
'\n')
30 B = canonical_contents.split(
'\n')
31 while len(A) < len(B):
33 while len(B) < len(A):
35 for a, b
in zip(A, B):
36 print(a == b, repr(a), repr(b))
40 if __name__ ==
'__main__':
41 parser = argparse.ArgumentParser()
42 parser.add_argument(
'zipfile')
43 parser.add_argument(
'-f',
'--fail_once', action=
'store_true')
44 parser.add_argument(
'-l',
'--last', action=
'store_true')
45 args = parser.parse_args()
51 for test_config
in config:
52 if args.last
and test_config != config[-1]:
55 with cases[test_config[
'in']]
as pkg_in:
58 if test_config[
'in'] == test_config[
'out']:
59 pkg_out = pkg_in.copy()
61 pkg_out = cases[test_config[
'out']]
63 print(
'{:25} >> {:25} {}'.format(test_config[
'in'], test_config[
'out'],
64 ','.join(test_config[
'functions'])))
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)
84 except Exception
as e:
85 print(
' EXCEPTION', e.message)
91 print(
'{}/{}'.format(successes, total))
def compare(pkg_in, pkg_out, debug=True)
def get_test_cases(zip_filename)