Make check_coverage.py work with coverage 4.4

With coverage 4.4, the source name (qutebrowser/) is not added to the filename
anymore. To adjust for that, we remove qutebrowser/ from all paths, and also
make sure to remove it from what coverage returns (in case someone is running an
older version).
This commit is contained in:
Florian Bruhin 2017-05-09 06:13:35 +02:00
parent 88545dec4d
commit 8052249b1b
2 changed files with 63 additions and 60 deletions

View File

@ -41,132 +41,132 @@ MsgType = enum.Enum('MsgType', 'insufficent_coverage, perfect_file')
# A list of (test_file, tested_file) tuples. test_file can be None.
PERFECT_FILES = [
(None,
'qutebrowser/commands/cmdexc.py'),
'commands/cmdexc.py'),
('tests/unit/commands/test_cmdutils.py',
'qutebrowser/commands/cmdutils.py'),
'commands/cmdutils.py'),
('tests/unit/commands/test_argparser.py',
'qutebrowser/commands/argparser.py'),
'commands/argparser.py'),
('tests/unit/browser/webkit/test_cache.py',
'qutebrowser/browser/webkit/cache.py'),
'browser/webkit/cache.py'),
('tests/unit/browser/webkit/test_cookies.py',
'qutebrowser/browser/webkit/cookies.py'),
'browser/webkit/cookies.py'),
('tests/unit/browser/webkit/test_history.py',
'qutebrowser/browser/history.py'),
'browser/history.py'),
('tests/unit/browser/webkit/test_history.py',
'qutebrowser/browser/webkit/webkithistory.py'),
'browser/webkit/webkithistory.py'),
('tests/unit/browser/webkit/http/test_http.py',
'qutebrowser/browser/webkit/http.py'),
'browser/webkit/http.py'),
('tests/unit/browser/webkit/http/test_content_disposition.py',
'qutebrowser/browser/webkit/rfc6266.py'),
'browser/webkit/rfc6266.py'),
# ('tests/unit/browser/webkit/test_webkitelem.py',
# 'qutebrowser/browser/webkit/webkitelem.py'),
# 'browser/webkit/webkitelem.py'),
# ('tests/unit/browser/webkit/test_webkitelem.py',
# 'qutebrowser/browser/webelem.py'),
# 'browser/webelem.py'),
('tests/unit/browser/webkit/network/test_schemehandler.py',
'qutebrowser/browser/webkit/network/schemehandler.py'),
'browser/webkit/network/schemehandler.py'),
('tests/unit/browser/webkit/network/test_filescheme.py',
'qutebrowser/browser/webkit/network/filescheme.py'),
'browser/webkit/network/filescheme.py'),
('tests/unit/browser/webkit/network/test_networkreply.py',
'qutebrowser/browser/webkit/network/networkreply.py'),
'browser/webkit/network/networkreply.py'),
('tests/unit/browser/test_signalfilter.py',
'qutebrowser/browser/signalfilter.py'),
'browser/signalfilter.py'),
(None,
'qutebrowser/browser/webkit/certificateerror.py'),
'browser/webkit/certificateerror.py'),
# ('tests/unit/browser/test_tab.py',
# 'qutebrowser/browser/tab.py'),
# 'browser/tab.py'),
('tests/unit/keyinput/test_basekeyparser.py',
'qutebrowser/keyinput/basekeyparser.py'),
'keyinput/basekeyparser.py'),
('tests/unit/misc/test_autoupdate.py',
'qutebrowser/misc/autoupdate.py'),
'misc/autoupdate.py'),
('tests/unit/misc/test_readline.py',
'qutebrowser/misc/readline.py'),
'misc/readline.py'),
('tests/unit/misc/test_split.py',
'qutebrowser/misc/split.py'),
'misc/split.py'),
('tests/unit/misc/test_msgbox.py',
'qutebrowser/misc/msgbox.py'),
'misc/msgbox.py'),
('tests/unit/misc/test_checkpyver.py',
'qutebrowser/misc/checkpyver.py'),
'misc/checkpyver.py'),
('tests/unit/misc/test_guiprocess.py',
'qutebrowser/misc/guiprocess.py'),
'misc/guiprocess.py'),
('tests/unit/misc/test_editor.py',
'qutebrowser/misc/editor.py'),
'misc/editor.py'),
('tests/unit/misc/test_cmdhistory.py',
'qutebrowser/misc/cmdhistory.py'),
'misc/cmdhistory.py'),
('tests/unit/misc/test_ipc.py',
'qutebrowser/misc/ipc.py'),
'misc/ipc.py'),
('tests/unit/misc/test_keyhints.py',
'qutebrowser/misc/keyhintwidget.py'),
'misc/keyhintwidget.py'),
('tests/unit/misc/test_pastebin.py',
'qutebrowser/misc/pastebin.py'),
'misc/pastebin.py'),
(None,
'qutebrowser/misc/objects.py'),
'misc/objects.py'),
(None,
'qutebrowser/mainwindow/statusbar/keystring.py'),
'mainwindow/statusbar/keystring.py'),
('tests/unit/mainwindow/statusbar/test_percentage.py',
'qutebrowser/mainwindow/statusbar/percentage.py'),
'mainwindow/statusbar/percentage.py'),
('tests/unit/mainwindow/statusbar/test_progress.py',
'qutebrowser/mainwindow/statusbar/progress.py'),
'mainwindow/statusbar/progress.py'),
('tests/unit/mainwindow/statusbar/test_tabindex.py',
'qutebrowser/mainwindow/statusbar/tabindex.py'),
'mainwindow/statusbar/tabindex.py'),
('tests/unit/mainwindow/statusbar/test_textbase.py',
'qutebrowser/mainwindow/statusbar/textbase.py'),
'mainwindow/statusbar/textbase.py'),
('tests/unit/mainwindow/statusbar/test_url.py',
'qutebrowser/mainwindow/statusbar/url.py'),
'mainwindow/statusbar/url.py'),
('tests/unit/mainwindow/test_messageview.py',
'qutebrowser/mainwindow/messageview.py'),
'mainwindow/messageview.py'),
('tests/unit/config/test_configtypes.py',
'qutebrowser/config/configtypes.py'),
'config/configtypes.py'),
('tests/unit/config/test_configdata.py',
'qutebrowser/config/configdata.py'),
'config/configdata.py'),
('tests/unit/config/test_configexc.py',
'qutebrowser/config/configexc.py'),
'config/configexc.py'),
('tests/unit/config/test_textwrapper.py',
'qutebrowser/config/textwrapper.py'),
'config/textwrapper.py'),
('tests/unit/config/test_style.py',
'qutebrowser/config/style.py'),
'config/style.py'),
('tests/unit/utils/test_qtutils.py',
'qutebrowser/utils/qtutils.py'),
'utils/qtutils.py'),
('tests/unit/utils/test_standarddir.py',
'qutebrowser/utils/standarddir.py'),
'utils/standarddir.py'),
('tests/unit/utils/test_urlutils.py',
'qutebrowser/utils/urlutils.py'),
'utils/urlutils.py'),
('tests/unit/utils/usertypes',
'qutebrowser/utils/usertypes.py'),
'utils/usertypes.py'),
('tests/unit/utils/test_utils.py',
'qutebrowser/utils/utils.py'),
'utils/utils.py'),
('tests/unit/utils/test_version.py',
'qutebrowser/utils/version.py'),
'utils/version.py'),
('tests/unit/utils/test_debug.py',
'qutebrowser/utils/debug.py'),
'utils/debug.py'),
('tests/unit/utils/test_jinja.py',
'qutebrowser/utils/jinja.py'),
'utils/jinja.py'),
('tests/unit/utils/test_error.py',
'qutebrowser/utils/error.py'),
'utils/error.py'),
('tests/unit/utils/test_typing.py',
'qutebrowser/utils/typing.py'),
'utils/typing.py'),
('tests/unit/utils/test_javascript.py',
'qutebrowser/utils/javascript.py'),
'utils/javascript.py'),
('tests/unit/completion/test_models.py',
'qutebrowser/completion/models/base.py'),
'completion/models/base.py'),
('tests/unit/completion/test_sortfilter.py',
'qutebrowser/completion/models/sortfilter.py'),
'completion/models/sortfilter.py'),
]
# 100% coverage because of end2end tests, but no perfect unit tests yet.
WHITELISTED_FILES = [
'qutebrowser/browser/webkit/webkitinspector.py',
'qutebrowser/keyinput/macros.py',
'qutebrowser/browser/webkit/webkitelem.py',
'browser/webkit/webkitinspector.py',
'keyinput/macros.py',
'browser/webkit/webkitelem.py',
]
@ -187,6 +187,8 @@ def _get_filename(filename):
common_path = os.path.commonprefix([basedir, filename])
if common_path:
filename = filename[len(common_path):].lstrip('/')
if filename.startswith('qutebrowser/'):
filename = filename.split('/', maxsplit=1)[1]
return filename

View File

@ -185,11 +185,12 @@ def test_skipped_windows(covtest, monkeypatch):
def _generate_files():
"""Get filenames from WHITELISTED_/PERFECT_FILES."""
yield from iter(check_coverage.WHITELISTED_FILES)
for src_file in check_coverage.WHITELISTED_FILES:
yield os.path.join('qutebrowser', src_file)
for test_file, src_file in check_coverage.PERFECT_FILES:
if test_file is not None:
yield test_file
yield src_file
yield os.path.join('qutebrowser', src_file)
@pytest.mark.parametrize('filename', list(_generate_files()))