Skip to content
Snippets Groups Projects
Commit a25ebed3 authored by Simon Glass's avatar Simon Glass
Browse files

binman: Check for files missing from test coverage


Files that are never imported are not shown in the test-coverage report.
Detect these and show an error.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent a9871c6e
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"""See README for more information""" """See README for more information"""
import glob
import os import os
import sys import sys
import traceback import traceback
...@@ -67,12 +68,27 @@ def RunTestCoverage(): ...@@ -67,12 +68,27 @@ def RunTestCoverage():
'tools/binman/binman.py -t' % options.build_dir) 'tools/binman/binman.py -t' % options.build_dir)
os.system(cmd) os.system(cmd)
stdout = command.Output('coverage', 'report') stdout = command.Output('coverage', 'report')
coverage = stdout.splitlines()[-1].split(' ')[-1] lines = stdout.splitlines()
test_set= set([os.path.basename(line.split()[0])
for line in lines if '/etype/' in line])
glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
all_set = set([os.path.basename(item) for item in glob_list])
missing_list = all_set
missing_list.difference_update(test_set)
missing_list.remove('_testing.py')
coverage = lines[-1].split(' ')[-1]
ok = True
if missing_list:
print 'Missing tests for %s' % (', '.join(missing_list))
ok = False
if coverage != '100%': if coverage != '100%':
print stdout print stdout
print "Type 'coverage html' to get a report in htmlcov/index.html" print "Type 'coverage html' to get a report in htmlcov/index.html"
raise ValueError('Coverage error: %s, but should be 100%%' % coverage) print 'Coverage error: %s, but should be 100%%' % coverage
ok = False
if not ok:
raise ValueError('Test coverage failure')
def RunBinman(options, args): def RunBinman(options, args):
"""Main entry point to binman once arguments are parsed """Main entry point to binman once arguments are parsed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment