run-tests: allow test output lines to be terminated with \r in addition to \n stable
authorMads Kiilerich <mads@kiilerich.com>
Wed, 26 Sep 2012 00:56:27 +0200
branchstable
changeset 1139 cdabdd17f980
parent 1138 bb419c4bfdd9
child 1140 689f8b6b711c
child 1142 2a75107bd979
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. [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Wed Oct 10 01:37:53 2012 +0200
+++ b/tests/run-tests.py	Wed Sep 26 00:56:27 2012 +0200
@@ -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 = []