changeset 42817:69506e1b3214

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
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 23 Aug 2019 08:54:32 -0700
parents fb84730d1c5a
children 0cbe17335857
files tests/run-tests.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Fri Aug 23 08:46:49 2019 -0700
+++ b/tests/run-tests.py	Fri Aug 23 08:54:32 2019 -0700
@@ -484,14 +484,6 @@
     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 @@
             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)