mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
17d82e7fd5
Normally changes in tests are reported like this in diffs: $ cat foo - a + b Using -i mode lets us update tests when the new results are correct and/or populate tests with their output. But with the standard doctest framework, inline Python sections in tests changes instead result in a big failure report that's unhelpful. So here, we replace the doctest calls with a simple compile/eval loop.
20 lines
500 B
Python
20 lines
500 B
Python
import sys
|
|
|
|
globalvars = {}
|
|
localvars = {}
|
|
lines = sys.stdin.readlines()
|
|
while lines:
|
|
l = lines.pop(0)
|
|
if l.startswith('SALT'):
|
|
print l[:-1]
|
|
elif l.startswith('>>> '):
|
|
snippet = l[4:]
|
|
while lines and lines[0].startswith('... '):
|
|
l = lines.pop(0)
|
|
snippet += "\n" + l[4:]
|
|
c = compile(snippet, '<heredoc>', 'single')
|
|
try:
|
|
exec c in globalvars, localvars
|
|
except Exception, inst:
|
|
print repr(inst)
|