utest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import inspect
3 from catkin.find_in_workspaces import find_in_workspaces
4 import zipfile_interface
5 from ros_introspection.package import Package
6 from roscompile import get_functions
7 import os.path
8 
9 FILE_ERROR_MESSAGE = 'These files should have been {} but weren\'t: {}'
10 
11 zipfile = find_in_workspaces(path='roscompile/test/test_data.zip', first_match_only=True)[0]
12 config, cases = zipfile_interface.get_test_cases(zipfile)
13 roscompile_functions = get_functions()
14 
15 
17  for test_config in config:
18  yield roscompile_check, test_config['in'], test_config['out'], \
19  test_config['functions'], test_config.get('subpkg', None), test_config.get('config', {})
20 
21 
22 def roscompile_check(input_package, output_package, list_o_functions, subpkg=None, local_config=None):
23  with cases[input_package] as pkg_in:
24  pkg_out = cases[output_package]
25 
26  root = pkg_in.root
27  if subpkg:
28  root = os.path.join(root, subpkg)
29  pp = Package(root)
30  for function_name in list_o_functions:
31  fne = roscompile_functions[function_name]
32  if 'config' in inspect.getargspec(fne).args:
33  fne(pp, config=local_config)
34  else:
35  fne(pp)
36  pp.write()
37 
38  matches, missed_deletes, missed_gens = pkg_in.compare_filesets(pkg_out)
39  assert len(missed_deletes) == 0, FILE_ERROR_MESSAGE.format('deleted', str(missed_deletes))
40  assert len(missed_gens) == 0, FILE_ERROR_MESSAGE.format('generated', str(missed_gens))
41  for filename in matches:
42  generated_contents = pkg_in.get_contents(filename).strip()
43  canonical_contents = pkg_out.get_contents(filename).strip()
44  assert generated_contents == canonical_contents, 'The contents of {} do not match!'.format(filename)
def roscompile_check(input_package, output_package, list_o_functions, subpkg=None, local_config=None)
Definition: utest.py:22
def test_generator()
Definition: utest.py:16


roscompile
Author(s):
autogenerated on Wed Jun 19 2019 19:56:53