From 969b905b6255070a2f539e5518baaa9888b7c516 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Mar 21 2017 12:40:36 +0000 Subject: Add performance totals plugin Signed-off-by: Patrick Uiterwijk --- diff --git a/nosetests b/nosetests index 2f5271b..646c4db 100755 --- a/nosetests +++ b/nosetests @@ -4,6 +4,7 @@ __requires__ = ['nose>=0.10.4', 'SQLAlchemy >= 0.7', 'jinja2 >= 2.4'] import sys from pkg_resources import load_entry_point -sys.exit( - load_entry_point('nose>=0.10.4', 'console_scripts', 'nosetests')() -) +import nose.core +from utils.perfplugin import PerfPlugin + +nose.core.main(addplugins=[PerfPlugin()]) diff --git a/runtests.sh b/runtests.sh index 3ceec59..1a84849 100755 --- a/runtests.sh +++ b/runtests.sh @@ -2,4 +2,4 @@ PAGURE_CONFIG=`pwd`/tests/test_config \ PYTHONPATH=pagure \ -./nosetests --with-coverage --cover-erase --cover-package=pagure $* +./nosetests --with-coverage --cover-erase --cover-package=pagure --with-pagureperf $* diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/utils/__init__.py diff --git a/utils/perfplugin.py b/utils/perfplugin.py new file mode 100644 index 0000000..2b270a9 --- /dev/null +++ b/utils/perfplugin.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +""" + (c) 2017 - Copyright Red Hat Inc + + Authors: + Patrick Uiterwijk + +""" + +import logging +import os + +from nose.plugins import Plugin + +import pagure.perfrepo as perfrepo + +log = logging.getLogger('nose.plugins.perfplugin') + + +class PerfPlugin(Plugin): + """A plugin for Nose that reports back on the test performance.""" + name = 'pagureperf' + + def options(self, parser, env=None): + if env is None: + env = os.environ + super(PerfPlugin, self).options(parser, env=env) + + def configure(self, options, conf): + super(PerfPlugin, self).configure(options, conf) + if not self.enabled: + return + + def report(self, stream): + stream.write('GIT PERFORMANCE TOTALS:\n') + stream.write('\tWalks: %d\n' % perfrepo.TOTALS['walks']) + stream.write('\tSteps: %d\n' % perfrepo.TOTALS['steps'])