# HG changeset patch # User Matt Mackall # Date 1320348600 18000 # Node ID 59fe460bb0f03cc2c9e82034569e3c5fcbda1b94 # Parent afc02adf4ded2537e3b6447d9d3767010d742631 tests: rewrite inline Python support Tests with inline Python could turn '>>>' into their underlying python invocation if the test got updated with -i. diff -r afc02adf4ded -r 59fe460bb0f0 tests/run-tests.py --- a/tests/run-tests.py Thu Nov 03 12:58:30 2011 -0500 +++ b/tests/run-tests.py Thu Nov 03 14:30:00 2011 -0500 @@ -521,26 +521,6 @@ def stringescape(s): return escapesub(escapef, s) -def transformtst(lines): - inblock = False - for l in lines: - if inblock: - if l.startswith(' $ ') or not l.startswith(' '): - inblock = False - yield ' > EOF\n' - yield l - else: - yield ' > ' + l[2:] - else: - if l.startswith(' >>> '): - inblock = True - yield ' $ %s -m heredoctest < ' + l[2:] - else: - yield l - if inblock: - yield ' > EOF\n' - def tsttest(test, wd, options, replacements): t = open(test) out = [] @@ -550,10 +530,24 @@ pos = prepos = -1 after = {} expected = {} - for n, l in enumerate(transformtst(t)): + inpython = False + for n, l in enumerate(t): if not l.endswith('\n'): l += '\n' - if l.startswith(' $ '): # commands + if l.startswith(' >>> '): + if not inpython: + # we've just entered a Python block, add the header + inpython = True + script.append('echo %s %s $?\n' % (salt, n)) + script.append('%s -m heredoctest <