tests/heredoctest.py
author Martin von Zweigbergk <martinvonz@google.com>
Mon, 17 Dec 2018 11:09:05 -0800
changeset 42909 32fdbc952bdd
parent 40318 55fd0fefbec4
child 43076 2372284d9457
permissions -rw-r--r--
tests: don't log manifest-file in test-strip-cross.t I'm confident that the file is there only to help produce a certain manifest log; there is nothing special about the file's filelog itself. (And there already is a `hg debugindex --manifest` call higher up in the file that shows the crossed linkrevs.) Differential Revision: https://phab.mercurial-scm.org/D6791

from __future__ import absolute_import, print_function

import sys

def flush():
    sys.stdout.flush()
    sys.stderr.flush()

globalvars = {}
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 += l[4:]
        c = compile(snippet, '<heredoc>', 'single')
        try:
            flush()
            exec(c, globalvars)
            flush()
        except Exception as inst:
            flush()
            print(repr(inst))