Patchwork [081,of,179,tests-refactor] run-tests: move option parser logic to TestRunner.run()

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

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1398013713 25200
#      Sun Apr 20 10:08:33 2014 -0700
# Branch stable
# Node ID 07c0013cf11e4c4f938a541792a4543a55e3fa48
# Parent  8669a3597f7f9c2c9a6697ba9820f742b7c4fa75
run-tests: move option parser logic to TestRunner.run()

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1007,23 +1007,27 @@  class TestRunner(object):
             '!': [],
             '~': [],
             's': [],
             'i': [],
         }
         self.abort = [False]
         self._createdfiles = []
 
-    def run(self, args):
+    def run(self, args, parser=None):
         """Run the test suite."""
 
         # Be kind and try to clean up after ourselves.
         oldenv = dict(os.environ)
         oldmask = os.umask(022)
         try:
+            parser = parser or getparser()
+            options, args = parseargs(args, parser)
+            self.options = options
+
             self._checktools()
             tests = self.findtests(args)
 
             return self._run(tests)
         finally:
             os.umask(oldmask)
             os.environ.clear()
             os.environ.update(oldenv)
@@ -1459,16 +1463,12 @@  class TestRunner(object):
             if found:
                 vlog("# Found prerequisite", p, "at", found)
             else:
                 print "WARNING: Did not find prerequisite tool: %s " % p
 
 def main(args, runner=None, parser=None):
     runner = runner or TestRunner()
 
-    parser = parser or getparser()
-    (options, args) = parseargs(args, parser)
-    runner.options = options
-
-    return runner.run(args)
+    return runner.run(args, parser=parser)
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))