[PATCH 2 of 3] run-tests: allow test output lines to be terminated with \r in addition to \n

Mads Kiilerich mads at kiilerich.com
Tue Oct 9 18:41:10 CDT 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1348613787 -7200
# Node ID 2d3adfec4624db760777ac23c003f3a9b335aa5b
# Parent  237c947af3cbc80516c959b4ea1c8f8ccb2151fa
run-tests: allow test output lines to be terminated with \r in addition to \n

str.splitlines could not be used in 546c76e5a3e6, but _now_ we would like to
have lines with other line endings than \n.

Some fine occurences of (esc) markup of \r is replaced with multiple lines
ending with '\r (no-eol) (esc)'.  That is no win but also no significant loss.

This change makes it possible to drop filtercr.py - _that_ is a win.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -283,21 +283,6 @@
     shutil.copy(src, dst)
     os.remove(src)
 
-def splitnewlines(text):
-    '''like str.splitlines, but only split on newlines.
-    keep line endings.'''
-    i = 0
-    lines = []
-    while True:
-        n = text.find('\n', i)
-        if n == -1:
-            last = text[i:]
-            if last:
-                lines.append(last)
-            return lines
-        lines.append(text[i:n + 1])
-        i = n + 1
-
 def parsehghaveoutput(lines):
     '''Parse hghave log lines.
     Return tuple of lists (missing, failed):
@@ -761,7 +746,7 @@
 
     for s, r in replacements:
         output = re.sub(s, r, output)
-    return ret, splitnewlines(output)
+    return ret, output.splitlines(True)
 
 def runone(options, test):
     '''tristate output:
@@ -924,7 +909,7 @@
         refout = None                   # to match "out is None"
     elif os.path.exists(ref):
         f = open(ref, "r")
-        refout = list(splitnewlines(f.read()))
+        refout = f.read().splitlines(True)
         f.close()
     else:
         refout = []
diff --git a/tests/test-diff-ignore-whitespace.t b/tests/test-diff-ignore-whitespace.t
--- a/tests/test-diff-ignore-whitespace.t
+++ b/tests/test-diff-ignore-whitespace.t
@@ -404,7 +404,8 @@
   -goodbye world
   +hello world\r (esc)
   +\r (esc)
-  +goodbye\rworld (esc)
+  +goodbye\r (no-eol) (esc)
+  world
 
 No completely blank lines to ignore:
 
@@ -417,7 +418,8 @@
   -goodbye world
   +hello world\r (esc)
   +\r (esc)
-  +goodbye\rworld (esc)
+  +goodbye\r (no-eol) (esc)
+  world
 
 Only new line noticed:
 
diff --git a/tests/test-diff-newlines.t b/tests/test-diff-newlines.t
--- a/tests/test-diff-newlines.t
+++ b/tests/test-diff-newlines.t
@@ -13,6 +13,7 @@
   +++ b/a	Thu Jan 01 00:00:02 1970 +0000
   @@ -1,2 +1,3 @@
    confuse str.splitlines
-   embedded\rnewline (esc)
+   embedded\r (no-eol) (esc)
+  newline
   +clean diff
 
diff --git a/tests/test-eolfilename.t b/tests/test-eolfilename.t
--- a/tests/test-eolfilename.t
+++ b/tests/test-eolfilename.t
@@ -9,11 +9,13 @@
   $ A=`printf 'he\rllo'`
   $ echo foo > "$A"
   $ hg add
-  adding he\rllo (esc)
+  adding he\r (no-eol) (esc)
+  llo
   abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
   [255]
   $ hg ci -A -m m
-  adding he\rllo (esc)
+  adding he\r (no-eol) (esc)
+  llo
   abort: '\n' and '\r' disallowed in filenames: 'he\rllo'
   [255]
   $ rm "$A"
@@ -31,7 +33,9 @@
   [255]
   $ echo foo > "$A"
   $ hg debugwalk
-  f  he\rllo  he\rllo (esc)
+  f  he\r (no-eol) (esc)
+  llo  he\r (no-eol) (esc)
+  llo
   f  hell
   o  hell
   o
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1127,9 +1127,13 @@
   
   x\x9c\xbdTMHTQ\x14\x1e\xfc\xef\xd9&\x10\x11*x\x88\x81\x9aN\xf7\xddw\xdf{\xf7Y\x0efR\xb4\x11\xb1U\x82\xc5\xfd\x9d!c\x06\x9c'd\xa0\x99X\x82\x92i\xablUZ-*\x08\x84\x82\x02KkQ\xf8\x13\xe4\xaa\x8dn\x94\x906)\xd5B\x02\xeb\xbe\x9c\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\x11\xe0\x02\xc8l\xe9H\x84\xb0\xf4\xa78\xc9-\xf1(\xa9\x15\x0f.\x8c\x8fT\x16\x965\xe9'\xbe\xac6\xaeLtN\x0f\x0e/fJ-\x8d\x08s\x12#\xe7[\xfe\xff\x0b\x17\xb9\xc6KK\xfa\xa2o\xa7\x1e\x87\xfaKb\x8b\xaf?\xcc\xed{z>\xd3\xb8\xbb\xcc}\x8eB\x01\x89\xc6\xbc\x88hO\xa6\x15\xf8\rr4\xb3\xe5 (no-eol) (esc)
+  \xd5~u\xb0e#\x08\r (no-eol) (esc)
+  \x8c\xd5\xf83\x93\x01B\x95\xe8\x1c\x03\xdb\x92s*\x99`\xcc0\x88\xb4d\xb2\xbd\x85\xc9,\x14\xb7\xf1\xd9\xf2\xe5Ku\x8d\xf5rp\xb6\xee\\\xe0\xc5\xa7C\xd9\xd7\xefe\xda\xe94\xc5\xaa\xde>\x8a\x02I\xcb!\x16\xc1\x10"\x1b\x11\xe0\x02\xc8l\xe9H\x84\xb0\xf4\xa78\xc9-\xf1(\xa9\x15\x0f.\x8c\x8fT\x16\x965\xe9'\xbe\xac6\xaeLtN\x0f\x0e/fJ-\x8d\x08s\x12#\xe7[\xfe\xff\x0b\x17\xb9\xc6KK\xfa\xa2o\xa7\x1e\x87\xfaKb\x8b\xaf?\xcc\xed{z>\xd3\xb8\xbb\xcc}\x8eB\x01\x89\xc6\xbc\x88hO\xa6\x15\xf8\r (no-eol) (esc)
+  r4\xb3\xe5 (no-eol) (esc)
 
 stream_out
 


More information about the Mercurial-devel mailing list