Mercurial > hg
changeset 21340:fda36de1cb0e
run-tests: establish a class to hold testing state
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 23:07:17 -0700 |
parents | de25e968b4d8 |
children | cb88d4a04f58 |
files | tests/run-tests.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Apr 19 22:02:55 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 23:07:17 2014 -0700 @@ -1182,7 +1182,7 @@ iolock = threading.Lock() abort = False -def scheduletests(options, tests): +def scheduletests(runner, options, tests): jobs = options.jobs done = queue.Queue() running = 0 @@ -1222,7 +1222,7 @@ except KeyboardInterrupt: abort = True -def runtests(options, tests): +def runtests(runner, options, tests): try: if INST: installhg(options) @@ -1240,7 +1240,7 @@ print "running all tests" tests = orig - scheduletests(options, tests) + scheduletests(runner, options, tests) failed = len(results['!']) warned = len(results['~']) @@ -1278,7 +1278,15 @@ testtypes = [('.py', PythonTest, '.out'), ('.t', TTest, '')] +class TestRunner(object): + """Holds context for executing tests. + + Tests rely on a lot of state. This object holds it for them. + """ + def main(args, parser=None): + runner = TestRunner() + parser = parser or getparser() (options, args) = parseargs(args, parser) os.umask(022) @@ -1397,7 +1405,7 @@ vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH]) try: - return runtests(options, tests) or 0 + return runtests(runner, options, tests) or 0 finally: time.sleep(.1) cleanup(options)