Mercurial > hg
comparison tests/run-tests.py @ 25107:149cc7663ac8
run-tests: add a --profile-runner 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.
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 13 May 2015 11:22:06 -0700 |
parents | bf84ab53c2fd |
children | 6ab5a1c9ea3c |
comparison
equal
deleted
inserted
replaced
25106:6f15114bdcc3 | 25107:149cc7663ac8 |
---|---|
238 help="enable Py3k warnings on Python 2.6+") | 238 help="enable Py3k warnings on Python 2.6+") |
239 parser.add_option('--extra-config-opt', action="append", | 239 parser.add_option('--extra-config-opt', action="append", |
240 help='set the given config opt in the test hgrc') | 240 help='set the given config opt in the test hgrc') |
241 parser.add_option('--random', action="store_true", | 241 parser.add_option('--random', action="store_true", |
242 help='run tests in random order') | 242 help='run tests in random order') |
243 parser.add_option('--profile-runner', action='store_true', | |
244 help='run statprof on run-tests') | |
243 | 245 |
244 for option, (envvar, default) in defaults.items(): | 246 for option, (envvar, default) in defaults.items(): |
245 defaults[option] = type(default)(os.environ.get(envvar, default)) | 247 defaults[option] = type(default)(os.environ.get(envvar, default)) |
246 parser.set_defaults(**defaults) | 248 parser.set_defaults(**defaults) |
247 | 249 |
1658 args = [a.encode('utf-8') for a in args] | 1660 args = [a.encode('utf-8') for a in args] |
1659 self.options = options | 1661 self.options = options |
1660 | 1662 |
1661 self._checktools() | 1663 self._checktools() |
1662 tests = self.findtests(args) | 1664 tests = self.findtests(args) |
1663 return self._run(tests) | 1665 if options.profile_runner: |
1666 import statprof | |
1667 statprof.start() | |
1668 result = self._run(tests) | |
1669 if options.profile_runner: | |
1670 statprof.stop() | |
1671 statprof.display() | |
1672 return result | |
1673 | |
1664 finally: | 1674 finally: |
1665 os.umask(oldmask) | 1675 os.umask(oldmask) |
1666 | 1676 |
1667 def _run(self, tests): | 1677 def _run(self, tests): |
1668 if self.options.random: | 1678 if self.options.random: |