Mercurial > public > mercurial-scm > hg
changeset 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 | eef540baab65 |
children | 181af28757f9 |
files | tests/heredoctest.py tests/run-tests.py tests/testlib/heredoctest.py |
diffstat | 3 files changed, 30 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/heredoctest.py Thu Jan 02 22:19:55 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -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))
--- a/tests/run-tests.py Thu Jan 02 22:19:55 2025 +0100 +++ b/tests/run-tests.py Thu Jan 02 16:22:14 2025 +0100 @@ -2034,9 +2034,9 @@ # We've just entered a Python block. Add the header. inpython = True addsalt(prepos, False) # Make sure we report the exit code. - script.append( - b'"%s" -m heredoctest <<EOF\n' % self._pythonb - ) + pyh = b'"%s" %s/testlib/heredoctest.py <<EOF\n' + pyh %= (self._pythonb, RUNTEST_DIR_FORWARD_SLASH) + script.append(pyh) addsalt(n, True) script.append(l[2:]) elif l.startswith(b' ... '): # python inlines
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testlib/heredoctest.py Thu Jan 02 16:22:14 2025 +0100 @@ -0,0 +1,27 @@ +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))