Mercurial > hg
changeset 21008:c1dd04be3d9a
run-tests: allow option parser to be extended
This patch moves the OptionParser population into its own function so
consumers may modify the OptionParser before arguments are evaluated.
This will allow consumers to add custom options, set different defaults,
etc.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 21:52:28 -0700 |
parents | 57179a4bf77a |
children | 990f5392c018 |
files | tests/run-tests.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Mon Mar 24 21:41:56 2014 -0700 +++ b/tests/run-tests.py Mon Mar 24 21:52:28 2014 -0700 @@ -133,7 +133,7 @@ f.close() return entries -def parseargs(args): +def getparser(): parser = optparse.OptionParser("%prog [options] [tests]") # keep these sorted @@ -210,6 +210,10 @@ for option, (envvar, default) in defaults.items(): defaults[option] = type(default)(os.environ.get(envvar, default)) parser.set_defaults(**defaults) + + return parser + +def parseargs(args, parser): (options, args) = parser.parse_args(args) # jython is always pure @@ -1176,8 +1180,9 @@ testtypes = [('.py', pytest, '.out'), ('.t', tsttest, '')] -def main(args): - (options, args) = parseargs(args) +def main(args, parser=None): + parser = parser or getparser() + (options, args) = parseargs(args, parser) os.umask(022) checktools()