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

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:38 p.m.
Message ID <ba68428f7499929e1e41.1399055906@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4564/
State Accepted
Commit 558246fa98b884847b2b6772a2f95ebfbdb6d897
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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()