changeset 21006:723e41ad59b4

run-tests: Pass arguments into argument parser Before, arguments were not passed into the optparse.OptionParser instance and were coming from sys.argv. This patch enables consumers to define the list of arguments to parse without having to adjust sys.argv.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Mar 2014 21:37:33 -0700
parents 3d38ebb586fe
children 57179a4bf77a
files tests/run-tests.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Fri Apr 11 07:36:14 2014 -0700
+++ b/tests/run-tests.py	Mon Mar 24 21:37:33 2014 -0700
@@ -133,7 +133,7 @@
         f.close()
     return entries
 
-def parseargs():
+def parseargs(args):
     parser = optparse.OptionParser("%prog [options] [tests]")
 
     # keep these sorted
@@ -210,7 +210,7 @@
     for option, (envvar, default) in defaults.items():
         defaults[option] = type(default)(os.environ.get(envvar, default))
     parser.set_defaults(**defaults)
-    (options, args) = parser.parse_args()
+    (options, args) = parser.parse_args(args)
 
     # jython is always pure
     if 'java' in sys.platform or '__pypy__' in sys.modules:
@@ -1176,8 +1176,8 @@
 testtypes = [('.py', pytest, '.out'),
              ('.t', tsttest, '')]
 
-def main():
-    (options, args) = parseargs()
+def main(args):
+    (options, args) = parseargs(args)
     os.umask(022)
 
     checktools()
@@ -1299,4 +1299,4 @@
         cleanup(options)
 
 if __name__ == '__main__':
-    main()
+    main(sys.argv[1:])