[PATCH 3 of 4] run-tests: add canonpath function

timeless timeless at mozdev.org
Mon Mar 28 00:03:16 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1459137681 0
#      Mon Mar 28 04:01:21 2016 +0000
# Node ID 7f96bdcef62d5f99417097ee441864298d1e4bd3
# Parent  21da80ece03e0cd5fc31fe8d265c8d1a72c2a206
run-tests: add canonpath function

consistently use realpath+expanduser

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -151,6 +151,9 @@
     'shell': ('HGTEST_SHELL', 'sh'),
 }
 
+def canonpath(path):
+    return os.path.realpath(os.path.expanduser(path))
+
 def parselistfiles(files, listtype, warn=True):
     entries = dict()
     for filename in files:
@@ -290,15 +293,14 @@
         options.pure = True
 
     if options.with_hg:
-        options.with_hg = os.path.realpath(
-            os.path.expanduser(_bytespath(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 not os.path.basename(options.with_hg) == b'hg':
             sys.stderr.write('warning: --with-hg should specify an hg script\n')
     if options.local:
-        testdir = os.path.dirname(_bytespath(os.path.realpath(sys.argv[0])))
+        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'
@@ -309,8 +311,7 @@
         parser.error('chg does not work on %s' % os.name)
     if options.with_chg:
         options.chg = False  # no installation to temporary location
-        options.with_chg = os.path.realpath(
-            os.path.expanduser(_bytespath(options.with_chg)))
+        options.with_chg = canonpath(_bytespath(options.with_chg))
         if not (os.path.isfile(options.with_chg) and
                 os.access(options.with_chg, os.X_OK)):
             parser.error('--with-chg must specify a chg executable')
@@ -343,7 +344,7 @@
         verbose = ''
 
     if options.tmpdir:
-        options.tmpdir = os.path.expanduser(options.tmpdir)
+        options.tmpdir = canonpath(options.tmpdir)
 
     if options.jobs < 1:
         parser.error('--jobs must be positive')


More information about the Mercurial-devel mailing list