Mercurial > public > mercurial-scm > hg
view tests/testlib/heredoctest.py @ 52594:b0ecab6773cf
run-tests: call heredoctest.py directly
Since we know exactly where it is, there is not need to use `python -m
heredoctest` to call it, we can just call that script.
We more the script in "testlib" to reduce the test directory clutter. We might
want to create a "tooling" directory in the future for this kind of utility.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Jan 2025 16:22:14 +0100 |
parents | tests/heredoctest.py@6000f5b25c9b |
children |
line wrap: on
line source
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))