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

login
register
mail settings
Submitter Simon Heimberg
Date July 13, 2013, 10:25 p.m.
Message ID <9baf643dca269dde0791.1373754312@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1882/
State Accepted
Commit 4f32747879d1d66bae623da6a80ec6a6a85299f4
Headers show

Comments

Simon Heimberg - July 13, 2013, 10:25 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@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.
Matt Mackall - July 17, 2013, 7:55 p.m.
On Sun, 2013-07-14 at 00:25 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1373752681 -7200
> # Node ID 9baf643dca269dde0791972e6f4f092b1913ee2d
> # Parent  982668dfa95a3adf94bd166e8a443e887774cd47
> run-tests: generally handle line endings on windows by re

Queued for default, thanks.

Patch

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