[PATCH against-clowncopter] run-tests: add a --profile option
Augie Fackler
raf at durin42.com
Thu May 14 00:42:50 UTC 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1431541326 25200
# Wed May 13 11:22:06 2015 -0700
# Node ID 21735d2bcefb10605708a1dc640a6cfa590c1361
# Parent 130c305f79910395cbfb73a442cc512605f78bc5
run-tests: add a --profile option
While in the throes of a recent run-tests adventure, I found it useful
to have profiler output for the testrunner itself. Adding it was
simple enough and seems worth keeping around.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -240,6 +240,8 @@ def getparser():
help='set the given config opt in the test hgrc')
parser.add_option('--random', action="store_true",
help='run tests in random order')
+ parser.add_option('--profile', action='store_true',
+ help='run statprof on run-tests')
for option, (envvar, default) in defaults.items():
defaults[option] = type(default)(os.environ.get(envvar, default))
@@ -1653,7 +1655,15 @@ class TestRunner(object):
self._checktools()
tests = self.findtests(args)
- return self._run(tests)
+ if options.profile:
+ import statprof
+ statprof.start()
+ result = self._run(tests)
+ if options.profile:
+ statprof.stop()
+ statprof.display()
+ return result
+
finally:
os.umask(oldmask)
More information about the Mercurial-devel
mailing list