unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/4] test: define test_expect_equal_message_body
Date: Thu, 20 Jan 2022 08:33:52 -0400	[thread overview]
Message-ID: <20220120123354.3999579-3-david@tethera.net> (raw)
In-Reply-To: <20220120123354.3999579-1-david@tethera.net>

This is a relatively simple sed invocation, but rather than write a
comment everywhere, give it a descriptive name.
---
 test/test-lib.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index f1275b85..661c0dd5 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -432,6 +432,20 @@ test_expect_equal_file () {
     test_diff_file_ "$1" "$2"
 }
 
+# Like test_expect_equal_file, but compare the part of the two files after the first blank line
+test_expect_equal_message_body () {
+    exec 1>&6 2>&7		# Restore stdout and stderr
+    if [ -z "$inside_subtest" ]; then
+	error "bug in the test script: test_expect_equal_file without test_begin_subtest"
+    fi
+    test "$#" = 2 ||
+	error "bug in the test script: not 2 parameters to test_expect_equal_file"
+
+    expected=$(sed -n '/^$/,$p' $1)
+    output=$(sed -n '/^$/,$p' $2)
+    test_expect_equal "$expected" "$output"
+}
+
 # Like test_expect_equal, but takes two filenames. Fails if either is empty
 test_expect_equal_file_nonempty () {
     exec 1>&6 2>&7		# Restore stdout and stderr
-- 
2.34.1

  parent reply	other threads:[~2022-01-20 12:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 12:33 fix Fcc of signed / encrypted messages David Bremner
2022-01-20 12:33 ` [PATCH 1/4] test/emacs: match mml settings in emacs_{fcc,deliver}_message David Bremner
2022-01-20 12:33 ` David Bremner [this message]
2022-01-20 22:16   ` [PATCH 2/4] test: define test_expect_equal_message_body Tomi Ollila
2022-01-22  2:56     ` David Bremner
2022-01-20 12:33 ` [PATCH 3/4] test/emacs: known broken test for matching fcc and sent message David Bremner
2022-01-20 12:33 ` [PATCH 4/4] emacs: use cached encoded copy for fcc David Bremner
2022-01-26 11:38 ` fix Fcc of signed / encrypted messages 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=20220120123354.3999579-3-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /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).