# HG changeset patch # User Gregory Szorc # Date 1395722253 25200 # Node ID 58a33a3ed565ba5961e882da0b5c039dc88b76f7 # Parent 1d3aa8779efb211ffaa9095349e242f1269878f9 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 ] diff -r 1d3aa8779efb -r 58a33a3ed565 tests/run-tests.py --- 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:])