[PATCH 069 of 179 tests-refactor] run-tests: allow TestRunner to be passed into main()

Gregory Szorc gregory.szorc at gmail.com
Fri May 2 13:38:26 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1398012027 25200
#      Sun Apr 20 09:40:27 2014 -0700
# Branch stable
# Node ID ba68428f7499929e1e412d1d6400f80283908a7e
# Parent  ffd38bfe92ba73742bf11d95f0215d46575b8034
run-tests: allow TestRunner to be passed into main()

This allows 3rd parties to specify a custom TestRunner. This is useful
for providing your own test discovery mechanism, for example.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1324,18 +1324,18 @@ class TestRunner(object):
                     t = threading.Thread(target=job, name=test,
                                          args=(test, count))
                     t.start()
                     running += 1
                     count += 1
         except KeyboardInterrupt:
             self.abort[0] = True
 
-def main(args, parser=None):
-    runner = TestRunner()
+def main(args, runner=None, parser=None):
+    runner = runner or TestRunner()
 
     parser = parser or getparser()
     (options, args) = parseargs(args, parser)
     runner.options = options
     os.umask(022)
 
     checktools()
 


More information about the Mercurial-devel mailing list