changeset 12940:518dd70d1a6e stable

tests: (no-eol) markup for command output without trailing LF Output chunks without a trailing LF will now work but get (no-eol) appended. This change mostly moves code around so we can handle that an output line starts with data from previous command, followed by salt and the next command.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 08 Nov 2010 01:35:40 +0100
parents ea7ad8c3988a
children b911cb80c671
files tests/run-tests.py tests/test-run-tests.t
diffstat 2 files changed, 28 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sat Nov 06 00:31:44 2010 +0100
+++ b/tests/run-tests.py	Mon Nov 08 01:35:40 2010 +0100
@@ -531,29 +531,37 @@
     postout = []
     ret = 0
     for n, l in enumerate(output):
-        if l.startswith(salt):
+        lout, lcmd = l, None
+        if salt in l:
+            lout, lcmd = l.split(salt, 1)
+
+        if lout:
+            if lcmd:
+                lout += ' (no-eol)\n'
+
+            el = None
+            if pos in expected and expected[pos]:
+                el = expected[pos].pop(0)
+
+            if el == lout: # perfect match (fast)
+                postout.append("  " + lout)
+            elif el and el.decode('string-escape') == l:
+                postout.append("  " + el)  # \-escape match
+            elif (el and
+                  (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or
+                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout))):
+                postout.append("  " + el) # fallback regex/glob match
+            else:
+                postout.append("  " + lout) # let diff deal with it
+
+        if lcmd:
             # add on last return code
-            ret = int(l.split()[2])
+            ret = int(lcmd.split()[1])
             if ret != 0:
                 postout.append("  [%s]\n" % ret)
             if pos in after:
                 postout += after.pop(pos)
-            pos = int(l.split()[1])
-        else:
-            el = None
-            if pos in expected and expected[pos]:
-                el = expected[pos].pop(0)
-
-            if el == l: # perfect match (fast)
-                postout.append("  " + l)
-            elif el and el.decode('string-escape') == l:
-                postout.append("  " + el)  # \-escape match
-            elif (el and
-                  (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
-                   el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))):
-                postout.append("  " + el) # fallback regex/glob match
-            else:
-                postout.append("  " + l) # let diff deal with it
+            pos = int(lcmd.split()[0])
 
     if pos in after:
         postout += after.pop(pos)
--- a/tests/test-run-tests.t	Sat Nov 06 00:31:44 2010 +0100
+++ b/tests/test-run-tests.t	Mon Nov 08 01:35:40 2010 +0100
@@ -2,6 +2,8 @@
 
   $ echo foo
   foo
+  $ printf 'oh no'
+  oh no (no-eol)
   $ printf 'bar\nbaz\n' | cat
   bar
   baz