D6760: run-tests: handle --local before --with-hg

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Aug 23 21:06:07 UTC 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6760

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

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 @@
     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)



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list