Merge with stable
authorChristian Ebert <blacktrash@gmx.net>
Fri, 11 Nov 2011 09:39:33 +0000
changeset 1021 4ecaec765d76
parent 1020 5dc5c899428a (current diff)
parent 1019 e7fbd63e5a98 (diff)
child 1023 c7a801067441
Merge with stable
--- a/tests/hghave	Fri Nov 11 09:38:45 2011 +0000
+++ b/tests/hghave	Fri Nov 11 09:39:33 2011 +0000
@@ -161,7 +161,7 @@
     return matchoutput('p4 -V', r'Rev\. P4/') and matchoutput('p4d -V', r'Rev\. P4D/')
 
 def has_symlink():
-    return hasattr(os, "symlink")
+    return hasattr(os, "symlink") # FIXME: should also check file system and os
 
 def has_tla():
     return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
@@ -209,6 +209,15 @@
     except ImportError:
         return False
 
+def has_windows():
+    return os.name == 'nt'
+
+def has_system_sh():
+    return os.name != 'nt'
+
+def has_serve():
+    return os.name != 'nt' # gross approximation
+
 checks = {
     "baz": (has_baz, "GNU Arch baz client"),
     "bzr": (has_bzr, "Canonical's Bazaar client"),
@@ -231,14 +240,17 @@
     "p4": (has_p4, "Perforce server and client"),
     "pyflakes": (has_pyflakes, "Pyflakes python linter"),
     "pygments": (has_pygments, "Pygments source highlighting library"),
+    "serve": (has_serve, "platform and python can manage 'hg serve -d'"),
     "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"),
     "svn": (has_svn, "subversion client and admin tools"),
     "svn13": (has_svn13, "subversion client and admin tools >= 1.3"),
     "svn15": (has_svn15, "subversion client and admin tools >= 1.5"),
     "svn-bindings": (has_svn_bindings, "subversion python bindings"),
     "symlink": (has_symlink, "symbolic links"),
+    "system-sh": (has_system_sh, "system() uses sh"),
     "tla": (has_tla, "GNU Arch tla client"),
     "unix-permissions": (has_unix_permissions, "unix-style permissions"),
+    "windows": (has_windows, "Windows"),
 }
 
 def list_features():
--- a/tests/run-tests.py	Fri Nov 11 09:38:45 2011 +0000
+++ b/tests/run-tests.py	Fri Nov 11 09:39:33 2011 +0000
@@ -87,7 +87,7 @@
 SKIPPED_STATUS = 80
 SKIPPED_PREFIX = 'skipped: '
 FAILED_PREFIX  = 'hghave check failed: '
-PYTHON = sys.executable
+PYTHON = sys.executable.replace('\\', '/')
 IMPL_PATH = 'PYTHONPATH'
 if 'java' in sys.platform:
     IMPL_PATH = 'JYTHONPATH'
@@ -530,20 +530,22 @@
         return False
 
 def globmatch(el, l):
-    # The only supported special characters are * and ?. Escaping is
-    # supported.
+    # The only supported special characters are * and ? plus / which also
+    # matches \ on windows. Escaping of these caracters is supported.
     i, n = 0, len(el)
     res = ''
     while i < n:
         c = el[i]
         i += 1
-        if c == '\\' and el[i] in '*?\\':
+        if c == '\\' and el[i] in '*?\\/':
             res += el[i - 1:i + 1]
             i += 1
         elif c == '*':
             res += '.*'
         elif c == '?':
             res += '.'
+        elif c == '/' and os.name == 'nt':
+            res += '[/\\\\]'
         else:
             res += re.escape(c)
     return rematch(res, l)
@@ -554,7 +556,10 @@
     if (el and
         (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
          el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
-         el.endswith(" (esc)\n") and el.decode('string-escape') == l)):
+         el.endswith(" (esc)\n") and
+             (el[:-7].decode('string-escape') + '\n' == l or
+              el[:-7].decode('string-escape').replace('\r', '') +
+                  '\n' == l and os.name == 'nt'))):
         return True
     return False
 
@@ -638,7 +643,7 @@
             os.write(fd, l)
         os.close(fd)
 
-        cmd = '"%s" "%s"' % (options.shell, name)
+        cmd = '%s "%s"' % (options.shell, name)
         vlog("# Running", cmd)
         exitcode, output = run(cmd, wd, options, replacements)
         # do not merge output if skipped, return hghave message instead
@@ -862,15 +867,26 @@
 
     # Make a tmp subdirectory to work in
     testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
-        os.path.join(HGTMP, os.path.basename(test))
+        os.path.join(HGTMP, os.path.basename(test)).replace('\\', '/')
 
-    os.mkdir(testtmp)
-    ret, out = runner(testpath, testtmp, options, [
-        (re.escape(testtmp), '$TESTTMP'),
+    replacements = [
         (r':%s\b' % options.port, ':$HGPORT'),
         (r':%s\b' % (options.port + 1), ':$HGPORT1'),
         (r':%s\b' % (options.port + 2), ':$HGPORT2'),
-        ])
+        ]
+    if os.name == 'nt':
+        replacements.append((r'\r\n', '\n'))
+        replacements.append(
+            (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
+                     c in '/\\' and r'[/\\]' or
+                     c.isdigit() and c or
+                     '\\' + c
+                     for c in testtmp), '$TESTTMP'))
+    else:
+        replacements.append((re.escape(testtmp), '$TESTTMP'))
+
+    os.mkdir(testtmp)
+    ret, out = runner(testpath, testtmp, options, replacements)
     vlog("# Ret was:", ret)
 
     mark = '.'
--- a/tests/test-keyword.t	Fri Nov 11 09:38:45 2011 +0000
+++ b/tests/test-keyword.t	Fri Nov 11 09:39:33 2011 +0000
@@ -1,3 +1,5 @@
+  $ "$TESTDIR/hghave" symlink unix-permissions serve || exit 80
+
   $ cat <<EOF >> $HGRCPATH
   > [extensions]
   > keyword =
@@ -208,7 +210,7 @@
   Message-Id: <hg.a2392c293916*> (glob)
   To: Test
   
-  changeset a2392c293916 in $TESTTMP/Test
+  changeset a2392c293916 in $TESTTMP/Test (glob)
   details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
   description:
   	addsym
@@ -231,7 +233,7 @@
   Message-Id: <hg.ef63ca68695b*> (glob)
   To: Test
   
-  changeset ef63ca68695b in $TESTTMP/Test
+  changeset ef63ca68695b in $TESTTMP/Test (glob)
   details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
   description:
   	absym
@@ -797,7 +799,7 @@
   > default = ../Test
   > EOF
   $ hg incoming
-  comparing with $TESTTMP/Test
+  comparing with $TESTTMP/Test (glob)
   searching for changes
   changeset:   2:bb948857c743
   tag:         tip