[PATCH 2 of 5] run-tests: generally handle line endings on windows by re

Simon Heimberg simohe at besonet.ch
Sat Jul 13 17:25:12 CDT 2013


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1373752681 -7200
# Node ID 9baf643dca269dde0791972e6f4f092b1913ee2d
# Parent  982668dfa95a3adf94bd166e8a443e887774cd47
run-tests: generally handle line endings on windows by re

Recently this regexp was only appended when running a python test. When running
a tsttest there was a separate handling for each line type. Simplify and unify
this.

diff -r 982668dfa95a -r 9baf643dca26 tests/run-tests.py
--- a/tests/run-tests.py	Sam Jul 13 23:57:55 2013 +0200
+++ b/tests/run-tests.py	Sam Jul 13 23:58:01 2013 +0200
@@ -572,8 +572,6 @@
     py3kswitch = options.py3k_warnings and ' -3' or ''
     cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test)
     vlog("# Running", cmd)
-    if os.name == 'nt':
-        replacements.append((r'\r\n', '\n'))
     return run(cmd, wd, options, replacements, env)
 
 needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
@@ -588,8 +586,6 @@
 def rematch(el, l):
     try:
         # use \Z to ensure that the regex matches to the end of the string
-        if os.name == 'nt':
-            return re.match(el + r'\r?\n\Z', l)
         return re.match(el + r'\n\Z', l)
     except re.error:
         # el is an invalid regex
@@ -627,8 +623,6 @@
     if el:
         if el.endswith(" (esc)\n"):
             el = el[:-7].decode('string-escape') + '\n'
-        if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l:
-            return True
         if (el.endswith(" (re)\n") and rematch(el[:-6], l) or
             el.endswith(" (glob)\n") and globmatch(el[:-8], l)):
             return True
@@ -949,6 +943,7 @@
                      c.isdigit() and c or
                      '\\' + c
                      for c in testtmp), '$TESTTMP'))
+        replacements.append((r'\r\n', '\n'))
     else:
         replacements.append((re.escape(testtmp), '$TESTTMP'))
 


More information about the Mercurial-devel mailing list