Patchwork [7,of,9] contrib: make import-checker agree more with run-tests about heredocpy

login
register
mail settings
Submitter Augie Fackler
Date Aug. 24, 2017, 2:33 p.m.
Message ID <a4244fddca70195060f8.1503585208@imladris.local>
Download mbox | patch
Permalink /patch/23300/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 24, 2017, 2:33 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503434226 14400
#      Tue Aug 22 16:37:06 2017 -0400
# Node ID a4244fddca70195060f81b4e7975375dee9a0d8e
# Parent  3973af0b0ae185ab05b0ddd54867bbc23df6b701
contrib: make import-checker agree more with run-tests about heredocpy

run-tests.py and import-checker.py take wholly different approaches to
.t-tests, and the result was that they had different notions about
when a Python heredoc had ended, leading to conflicts. This resolves
part of the issue, and the rest I can deal with by tweaking the one
offending test file.

Patch

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -693,7 +693,10 @@  def embedded(f, modname, src):
             else:
                 script.append(l[4:])
             continue
-        if inlinepython and l == b'  \n':
+        # If we have an empty line or a command for sh, we end the
+        # inline script.
+        if inlinepython and (l == b'  \n'
+                             or l.startswith(b'  $ ')):
             yield b''.join(script), (b"%s[%d]" %
                    (modname, inlinepython)), t, inlinepython
             script = []