From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>,
Vladimir Panteleev <notmuch@thecybershadow.net>,
notmuch@notmuchmail.org
Subject: Re: [PATCH] test/crypto: remove headers more robustly
Date: Sat, 02 Sep 2017 22:48:56 +0300 [thread overview]
Message-ID: <m21sno7ufr.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <20170902001119.15318-1-david@tethera.net>
On Fri, Sep 01 2017, David Bremner wrote:
> In [1], Vladimir Panteleev observed that the In-Reply-To and
> References headers could be wrapped in the 'default' output format of
> notmuch-reply, depending on the version of Emacs creating the
> message. In my own experiments notmuch-reply sometimes wraps headers
> with only one message-id if that message-id is long enough. However it
> happens, this causes the previous approach using grep to fail.
we could (also) make emacs think it has wider than 80 characters to fit on
one line...
> Since I found the proposed unwrapping shell fragment in [1] a bit hard
> to follow, I decided to write a little python script instead.
There was nothing hard in that shell construct ;), but I also thought some
alternative solutions (one in awk and one in perl)
How 'bout
drop_email_headers ()
{
$NOTMUCH_PYTHON -c 'import email, sys
msg = email.message_from_file(sys.stdin)
for hdr in sys.argv: msg.pop(hdr, None)
print(msg.as_string(False))'
}
and then ... | drop_email_headers In-Reply-To References
>
> [1] id:20170817175145.3204-7-notmuch@thecybershadow.net
> ---
> test/T350-crypto.sh | 2 +-
> test/test-lib.sh | 11 +++++++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
> index 7dab39a2..fd950952 100755
> --- a/test/T350-crypto.sh
> +++ b/test/T350-crypto.sh
> @@ -394,7 +394,7 @@ test_expect_equal_json \
>
> test_begin_subtest "reply to encrypted message"
> output=$(notmuch reply --decrypt subject:"test encrypted message 002" \
> - | grep -v -e '^In-Reply-To:' -e '^References:')
> + | notmuch_reply_sanitize_refs)
> expected='From: Notmuch Test Suite <test_suite@notmuchmail.org>
> Subject: Re: test encrypted message 002
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index d2b2a47f..4716f649 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -507,6 +507,17 @@ NOTMUCH_DUMP_TAGS ()
> notmuch dump --include=tags "${@}" | sed '/^#/d' | sort
> }
>
> +notmuch_reply_sanitize_refs ()
> +{
> + $NOTMUCH_PYTHON -c "
> +import email,sys
> +msg=email.message_from_file(sys.stdin)
> +del msg['in-reply-to']
> +del msg['references']
> +print(msg.as_string(False))
> +"
> +}
> +
> notmuch_search_sanitize ()
> {
> perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
> --
> 2.14.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
next prev parent reply other threads:[~2017-09-02 19:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 17:51 [PATCH 0/7] Travis and test suite improvements Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 1/7] .travis.yml: Invoke `make download-test-databases' before running tests Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 2/7] .travis.yml: Add gdb and gpgsm dependencies Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 3/7] .travis.yml: Replace manual zlib installation with "dist: trusty" Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 4/7] test: Fix T050-new.sh on some Travis CI machines Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 5/7] .travis.yml: Switch to "sudo: false" for faster builds Vladimir Panteleev
2017-08-17 17:51 ` [PATCH 6/7] test: Fix T350-crypto.sh on Emacs snapshots Vladimir Panteleev
2017-09-02 0:11 ` [PATCH] test/crypto: remove headers more robustly David Bremner
2017-09-02 19:48 ` Tomi Ollila [this message]
2017-09-03 11:13 ` David Bremner
2017-08-17 17:51 ` [PATCH 7/7] .travis.yml: Test against several Emacs versions Vladimir Panteleev
2017-09-02 0:41 ` David Bremner
2017-09-04 21:31 ` Vladimir Panteleev
2017-08-30 23:19 ` [PATCH 0/7] Travis and test suite improvements David Bremner
2017-08-30 23:22 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m21sno7ufr.fsf@guru.guru-group.fi \
--to=tomi.ollila@iki.fi \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
--cc=notmuch@thecybershadow.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).