# HG changeset patch # User Martin von Zweigbergk # Date 2019-08-23 15:54:32 # Node ID 69506e1b321416274d0889059dbfe6c37a626462 # Parent fb84730d1c5ab7a1c2b29fd465500cc0ee82e138 run-tests: handle --local before --with-hg We no longer support them both together, so this is now safe to do. By checking --local first, we avoid error out about an invalid --with-hg script if --local was also given (we instead tell the user that the options are mutually exclusive). I also had to wrap the 'binpath' we pass to setattr() in _strpath() to keep `python3 run-tests.py -l` working. That change also made `python3 run-tests.py -l --chg` work, which was the reason for this series. Differential Revision: https://phab.mercurial-scm.org/D6760 diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -484,14 +484,6 @@ def parseargs(args, parser): if 'java' in sys.platform or '__pypy__' in sys.modules: options.pure = True - if options.with_hg: - options.with_hg = canonpath(_bytespath(options.with_hg)) - if not (os.path.isfile(options.with_hg) and - os.access(options.with_hg, os.X_OK)): - parser.error('--with-hg must specify an executable hg script') - if os.path.basename(options.with_hg) not in [b'hg', b'hg.exe']: - sys.stderr.write('warning: --with-hg should specify an hg script\n') - sys.stderr.flush() if options.local: if options.with_hg or options.with_chg: parser.error('--local cannot be used with --with-hg or --with-chg') @@ -505,7 +497,16 @@ def parseargs(args, parser): if os.name != 'nt' and not os.access(binpath, os.X_OK): parser.error('--local specified, but %r not found or ' 'not executable' % binpath) - setattr(options, attr, binpath) + setattr(options, attr, _strpath(binpath)) + + if options.with_hg: + options.with_hg = canonpath(_bytespath(options.with_hg)) + if not (os.path.isfile(options.with_hg) and + os.access(options.with_hg, os.X_OK)): + parser.error('--with-hg must specify an executable hg script') + if os.path.basename(options.with_hg) not in [b'hg', b'hg.exe']: + sys.stderr.write('warning: --with-hg should specify an hg script\n') + sys.stderr.flush() if (options.chg or options.with_chg) and os.name == 'nt': parser.error('chg does not work on %s' % os.name)