hows_my_coverage.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from catkin.find_in_workspaces import find_in_workspaces
3 import zipfile_interface
4 from roscompile import get_functions
5 import argparse
6 
7 parser = argparse.ArgumentParser()
8 parser.add_argument('zipfile', nargs='?')
9 args = parser.parse_args()
10 
11 if not args.zipfile:
12  args.zipfile = find_in_workspaces(path='roscompile/test/test_data.zip', first_match_only=True)[0]
13 config, cases = zipfile_interface.get_test_cases(args.zipfile)
14 roscompile_functions = get_functions()
15 coverage_counts = {}
16 max_len = 0
17 for name in roscompile_functions:
18  coverage_counts[name] = 0
19  max_len = max(max_len, len(name))
20 
21 for test_config in config:
22  for fne_name in test_config['functions']:
23  coverage_counts[fne_name] += 1
24 
25 z_count = 0
26 for name, count in sorted(coverage_counts.items(), key=lambda kv: kv[1], reverse=True):
27  print('{:{}} {:=3d}'.format(name, max_len, count))
28  if count == 0:
29  z_count += 1
30 
31 if z_count > 0:
32  print('Zero tests written for {} functions'.format(z_count))


roscompile
Author(s):
autogenerated on Wed Mar 3 2021 03:56:01