[PATCH 2 of 3] run-tests: allow --local to set multiple attributes

Jun Wu quark at fb.com
Mon Jul 18 04:08:47 EDT 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1468827946 -3600
#      Mon Jul 18 08:45:46 2016 +0100
# Node ID 92ee0f4dde62d10e9964aa02c3b0176cd628c081
# Parent  801ec794c36bcee6db09916311c62dff96729921
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 92ee0f4dde62
run-tests: allow --local to set multiple attributes

This is to make the next patch easier to review. It does not change logic.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -308,11 +308,14 @@ def parseargs(args, parser):
             sys.stderr.write('warning: --with-hg should specify an hg script\n')
     if options.local:
         testdir = os.path.dirname(_bytespath(canonpath(sys.argv[0])))
-        hgbin = os.path.join(os.path.dirname(testdir), b'hg')
-        if os.name != 'nt' and not os.access(hgbin, os.X_OK):
-            parser.error('--local specified, but %r not found or not executable'
-                         % hgbin)
-        options.with_hg = hgbin
+        reporootdir = os.path.dirname(testdir)
+        pathandattrs = [(b'hg', 'with_hg')]
+        for relpath, attr in pathandattrs:
+            binpath = os.path.join(reporootdir, relpath)
+            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)
 
     if (options.chg or options.with_chg) and os.name == 'nt':
         parser.error('chg does not work on %s' % os.name)


More information about the Mercurial-devel mailing list