tests/run-tests.py
changeset 28701 3bce3d2fd727
parent 28699 5cc59dbd199f
child 28812 f1de5a612a74
--- a/tests/run-tests.py	Wed Mar 30 07:24:51 2016 +0000
+++ b/tests/run-tests.py	Wed Mar 30 09:13:47 2016 +0000
@@ -1160,6 +1160,7 @@
                     els = expected[pos]
 
                 i = 0
+                optional = []
                 while i < len(els):
                     el = els[i]
 
@@ -1181,11 +1182,18 @@
                     if r:
                         els.pop(i)
                         break
+                    if el and el.endswith(b" (?)\n"):
+                        optional.append(i)
                     i += 1
 
                 if r:
                     if r == "retry":
                         continue
+                    # clean up any optional leftovers
+                    for i in optional:
+                        postout.append(b'  ' + els[i])
+                    for i in reversed(optional):
+                        del els[i]
                     postout.append(b'  ' + el)
                 else:
                     if self.NEEDESCAPE(lout):