Patchwork [STABLE] tests: handle Message-Id email header possible wrapping

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 28, 2019, 8:46 a.m.
Message ID <685f39b1643549f1642f.1572252394@marimba>
Download mbox | patch
Permalink /patch/42607/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 28, 2019, 8:46 a.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1572196344 -3600
#      Sun Oct 27 18:12:24 2019 +0100
# Branch stable
# Node ID 685f39b1643549f1642f062c99c2653f1327253c
# Parent  8fda98a6842709c26b61747c7420b28cd874755e
tests: handle Message-Id email header possible wrapping

The "Message-Id" header will get wrapped with a new line when exceeding
75 characters on Python 3 (see changeset 7d4f2e4899c5 introducing usage
of email.header.Header.encode and respective doc). This will occur in an
unpredictable manner depending on the hostname's length. To make the
test output consistent across Python versions and hostname
configuration, we add a filter to unwrap this header value.

---
This is expected to fix remaining issues on Python 3 for test-notify.t
and test-keyword.t as those in:

  https://ci.hg.gregoryszorc.com/job-info/hg-committed-8fda98a6842709c26b61747c7420b28cd874755e-debian10-cpython-3.7-0
Augie Fackler - Oct. 28, 2019, 7:18 p.m.
On Mon, Oct 28, 2019 at 09:46:34AM +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1572196344 -3600
> #      Sun Oct 27 18:12:24 2019 +0100
> # Branch stable
> # Node ID 685f39b1643549f1642f062c99c2653f1327253c
> # Parent  8fda98a6842709c26b61747c7420b28cd874755e
> tests: handle Message-Id email header possible wrapping

queued, thanks

Patch

diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -256,7 +256,8 @@  ie. if patch.diff wrapper acts as it sho
 
 Pull from bundle and trigger notify
 
-  $ hg pull -u ../kw.hg
+  $ hg pull -u ../kw.hg | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py
   pulling from ../kw.hg
   requesting all changes
   adding changesets
diff --git a/tests/test-notify.t b/tests/test-notify.t
--- a/tests/test-notify.t
+++ b/tests/test-notify.t
@@ -196,7 +196,9 @@  the python call below wraps continuation
 of the very long subject line
 pull (minimal config)
 
-  $ hg --traceback --cwd b --config notify.domain=example.com --config notify.messageidseed=example pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b --config notify.domain=example.com --config notify.messageidseed=example pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -211,8 +213,7 @@  pull (minimal config)
   Subject: changeset in $TESTTMP/b: b
   From: test@example.com
   X-Hg-Notification: changeset 00a13f371396
-  Message-Id: <hg.ba3098a36bd4c297288d16788623a841f81f618ea961a0f0fd65de7eb1191b66@example.com> (no-py3 !)
-  Message-Id:  <hg.ba3098a36bd4c297288d16788623a841f81f618ea961a0f0fd65de7eb1191b66@example.com> (py3 !)
+  Message-Id: <hg.ba3098a36bd4c297288d16788623a841f81f618ea961a0f0fd65de7eb1191b66@example.com>
   To: baz@example.com, foo@bar
   
   changeset 00a13f371396 in $TESTTMP/b
@@ -256,7 +257,9 @@  pull
 
   $ hg --cwd b rollback
   repository tip rolled back to revision 0 (undo pull)
-  $ hg --traceback --cwd b pull ../a  | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -304,7 +307,9 @@  pull
 
   $ hg --cwd b rollback
   repository tip rolled back to revision 0 (undo pull)
-  $ hg --traceback --config notify.maxdiffstat=1 --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --config notify.maxdiffstat=1 --cwd b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -355,7 +360,9 @@  test merge
   (branch merge, don't forget to commit)
   $ hg ci -m merge -d '3 0'
   $ cd ..
-  $ hg --traceback --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -421,6 +428,7 @@  non-ascii content and truncation of mult
   $ hg --cwd a --encoding utf-8 commit -A -d '0 0' \
   >   -m `"$PYTHON" -c 'import sys; getattr(sys.stdout, "buffer", sys.stdout).write(b"\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4")'`
   $ hg --traceback --cwd b --encoding utf-8 pull ../a | \
+  >   "$PYTHON" $TESTDIR/unwrap-message-id.py | \
   >   "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
@@ -475,7 +483,7 @@  long lines
   new changesets a846b5f6ebb7
   notify: sending 2 subscribers 1 changes
   (run 'hg update' to get a working copy)
-  $ "$PYTHON" $TESTTMP/filter.py < b/mbox
+  $ cat b/mbox | "$PYTHON" $TESTDIR/unwrap-message-id.py | "$PYTHON" $TESTTMP/filter.py
   From test@test.com ... ... .. ..:..:.. .... (re)
   MIME-Version: 1.0
   Content-Type: text/plain; charset="*" (glob)
@@ -535,7 +543,9 @@  long lines
   (branches are permanent and global, did you want a bookmark?)
   $ echo a >> a/a
   $ hg --cwd a ci -m test -d '1 0'
-  $ hg --traceback --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -565,7 +575,9 @@  from different branch
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo a >> a/a
   $ hg --cwd a ci -m test -d '1 0'
-  $ hg --traceback --cwd b pull ../a | "$PYTHON" $TESTTMP/filter.py
+  $ hg --traceback --cwd b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -594,7 +606,9 @@  default template:
   $ mv "$HGRCPATH.new" $HGRCPATH
   $ echo a >> a/a
   $ hg --cwd a commit -m 'default template'
-  $ hg --cwd b pull ../a -q | "$PYTHON" $TESTTMP/filter.py
+  $ hg --cwd b pull ../a -q | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
   Content-Transfer-Encoding: 7bit
@@ -623,7 +637,9 @@  with style:
   > EOF
   $ echo a >> a/a
   $ hg --cwd a commit -m 'with style'
-  $ hg --cwd b pull ../a -q | "$PYTHON" $TESTTMP/filter.py
+  $ hg --cwd b pull ../a -q | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
   Content-Transfer-Encoding: 7bit
@@ -646,7 +662,9 @@  with template (overrides style):
   > EOF
   $ echo a >> a/a
   $ hg --cwd a commit -m 'with template'
-  $ hg --cwd b pull ../a -q | "$PYTHON" $TESTTMP/filter.py
+  $ hg --cwd b pull ../a -q | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py | \
+  >  "$PYTHON" $TESTTMP/filter.py
   MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
   Content-Transfer-Encoding: 7bit
@@ -677,7 +695,8 @@  showfunc diff
   > EOF
   $ hg commit -Am addfunction
   adding f1
-  $ hg --cwd ../b pull ../a
+  $ hg --cwd ../b pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py
   pulling from ../a
   searching for changes
   adding changesets
@@ -720,7 +739,8 @@  showfunc diff
   > }
   > EOF
   $ hg commit -m changefunction
-  $ hg --cwd ../b --config notify.showfunc=True pull ../a
+  $ hg --cwd ../b --config notify.showfunc=True pull ../a | \
+  >  "$PYTHON" $TESTDIR/unwrap-message-id.py
   pulling from ../a
   searching for changes
   adding changesets
diff --git a/tests/unwrap-message-id.py b/tests/unwrap-message-id.py
new file mode 100644
--- /dev/null
+++ b/tests/unwrap-message-id.py
@@ -0,0 +1,6 @@ 
+from __future__ import absolute_import, print_function
+
+import re
+import sys
+
+print(re.sub(r"(?<=Message-Id:) \n ", " ", sys.stdin.read()), end="")