Merge with stable
authorChristian Ebert <blacktrash@gmx.net>
Thu, 13 Oct 2011 17:48:29 +0100
changeset 988 320bd57f76a3
parent 986 0f5e2d5e716b (current diff)
parent 987 5fc540826f9f (diff)
child 990 ab082912af32
Merge with stable
--- a/tests/run-tests.py	Sat Oct 08 00:24:35 2011 +0100
+++ b/tests/run-tests.py	Thu Oct 13 17:48:29 2011 +0100
@@ -521,6 +521,26 @@
 def stringescape(s):
     return escapesub(escapef, s)
 
+def transformtst(lines):
+    inblock = False
+    for l in lines:
+        if inblock:
+            if l.startswith('  $ '):
+                inblock = False
+                yield '  > EOF\n'
+                yield l
+            else:
+                yield '  > ' + l[2:]
+        else:
+            if l.startswith('  >>> '):
+                inblock = True
+                yield '  $ %s -m heredoctest <<EOF\n' % PYTHON
+                yield '  > ' + l[2:]
+            else:
+                yield l
+    if inblock:
+        yield '  > EOF\n'
+
 def tsttest(test, wd, options, replacements):
     t = open(test)
     out = []
@@ -530,7 +550,7 @@
     pos = prepos = -1
     after = {}
     expected = {}
-    for n, l in enumerate(t):
+    for n, l in enumerate(transformtst(t)):
         if not l.endswith('\n'):
             l += '\n'
         if l.startswith('  $ '): # commands
@@ -833,7 +853,7 @@
         refout = None                   # to match "out is None"
     elif os.path.exists(ref):
         f = open(ref, "r")
-        refout = splitnewlines(f.read())
+        refout = list(transformtst(splitnewlines(f.read())))
         f.close()
     else:
         refout = []