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.
[ original upstream message ]
--- a/tests/run-tests.py Fri Feb 28 02:09:00 2014 +0100
+++ 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:])