view tests/heredoctest.py @ 39466:83dd656586b1

tests: improve the widening testing in test-narrow-widen* Before this patch, we are testing `hg tracked --addinclude` by adding a command which is not introduced in the changesets till now. If you closely look at the tests, wider/f was introduced on the server after the narrow clone was done and extending the existing clone to include wider/f does not make sense. We should test extending a file which exists. Differential Revision: https://phab.mercurial-scm.org/D4452
author Pulkit Goyal <pulkit@yandex-team.ru>
date Tue, 04 Sep 2018 15:16:22 +0300
parents 6a98f9408a50
children 55fd0fefbec4
line wrap: on
line source

from __future__ import absolute_import, print_function

import sys

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:
            exec(c, globalvars)
        except Exception as inst:
            print(repr(inst))