tests/heredoctest.py
author Mads Kiilerich <madski@unity3d.com>
Wed, 16 Jan 2013 02:01:11 +0100
branchstable
changeset 1200 1a67e2797f33
parent 1110 d5b3404b82ce
permissions -rw-r--r--
tests: make test-hgweb.t output stable Instability introduced in combination of a4d7fd7ad1f7 and e389a25e7e60. [ original upstream message ]

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)