diff options
author | Florian Bruhin <git@the-compiler.org> | 2015-03-04 21:39:14 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2015-03-04 21:39:14 +0100 |
commit | 4fa5872733877ba03b031bde1527277347ee7233 (patch) | |
tree | 58978d1240e8f46cfe3a77fba48042c7ccb75075 | |
parent | ebae77e8c57b39a7968a7bd5ad7a1eb8c8d12adc (diff) | |
download | qutebrowser-4fa5872733877ba03b031bde1527277347ee7233.tar.gz qutebrowser-4fa5872733877ba03b031bde1527277347ee7233.zip |
Add coverage.py support to run_checks.py
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | scripts/init_venv.py | 2 | ||||
-rwxr-xr-x | scripts/run_checks.py | 21 |
3 files changed, 20 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore index 46e8eb96c..0ee617066 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ __pycache__ /README.html /qutebrowser/html/doc/ /.venv +/.coverage +/covhtml diff --git a/scripts/init_venv.py b/scripts/init_venv.py index 4f4f83141..dc31308a8 100644 --- a/scripts/init_venv.py +++ b/scripts/init_venv.py @@ -79,7 +79,7 @@ def get_dev_packages(short=False): short: Remove the version specification. """ packages = ['colorlog', 'flake8', 'astroid', 'pylint', 'pep257', - 'colorama', 'beautifulsoup4'] + 'colorama', 'beautifulsoup4', 'coverage'] if short: packages = [re.split(r'[<>=]', p)[0] for p in packages] return packages diff --git a/scripts/run_checks.py b/scripts/run_checks.py index 9806491ed..0219ae519 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -44,7 +44,7 @@ import contextlib import traceback import pep257 - +import coverage sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir)) @@ -151,10 +151,21 @@ def check_init(target): return ok -def check_unittest(): - """Run the unittest checker.""" +def check_unittest(run_coverage): + """Run the unittest checker. + + Args: + run_coverage: Whether to also run coverage.py. + """ + if run_coverage: + cov = coverage.coverage(branch=True, source=['qutebrowser']) + cov.erase() + cov.start() suite = unittest.TestLoader().discover('.') result = unittest.TextTestRunner().run(suite) + if run_coverage: + cov.stop() + cov.html_report() print() return result.wasSuccessful() @@ -268,7 +279,7 @@ def _get_checkers(args): # "Static" checkers checkers = collections.OrderedDict([ ('global', collections.OrderedDict([ - ('unittest', check_unittest), + ('unittest', functools.partial(check_unittest, args.coverage)), ('git', check_git), ])), ('setup', collections.OrderedDict([ @@ -303,6 +314,8 @@ def _checker_enabled(args, group, name): def _parse_args(): """Parse commandline args via argparse.""" parser = argparse.ArgumentParser(description='Run various checkers.') + parser.add_argument('-c', '--coverage', help="Also run coverage.py and " + "generate a HTML report.", action='store_true') parser.add_argument('-s', '--setup', help="Run additional setup checks", action='store_true') parser.add_argument('-q', '--quiet', |