From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +DuwOcpW6WE+kwAAgWs5BA (envelope-from ) for ; Thu, 20 Jan 2022 13:34:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kFoaN8pW6WGrSAEA9RJhRA (envelope-from ) for ; Thu, 20 Jan 2022 13:34:18 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B2F123AA8E for ; Thu, 20 Jan 2022 13:34:18 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 586605F710; Thu, 20 Jan 2022 12:34:08 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 76C865F6EC for ; Thu, 20 Jan 2022 12:34:05 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id E5C8C5FC03; Thu, 20 Jan 2022 07:34:04 -0500 (EST) Received: (nullmailer pid 4003272 invoked by uid 1000); Thu, 20 Jan 2022 12:34:02 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/4] test: define test_expect_equal_message_body Date: Thu, 20 Jan 2022 08:33:52 -0400 Message-Id: <20220120123354.3999579-3-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220120123354.3999579-1-david@tethera.net> References: <20220120123354.3999579-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: HHUVJDH2FSFS7HYYOGRHHYMDU6NFD6WA X-Message-ID-Hash: HHUVJDH2FSFS7HYYOGRHHYMDU6NFD6WA X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642682058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=V65FVy70w8Xqi5a50jpFw3Ah4v/RJ6rqH/nkGKTl1yE=; b=DrBkoQZXsteikChklwogzFyWMj4CGn7vWcMld7GlR6LhwHPWUZBbN7GmOoWDTYBvXY3sne m4RKi8+h4cUlpm04CQmZeNEGr55DMfbmpcAUNcepJQH2kBcWbP8aKLjELOSzZJkegVQXHm tZE3k7RF+cZ9zvhSpTgd0ZJTgAloLWkRe59Q4EzX/oI0J0XXgAt0XTMfnSsEx+Cx/ys9jT 3OK/PCwJHX20OwgelFAEYPWNS/3xdP+KQCPiUOsCFxbKfVfKTmbBXVrLBZ7Enwa49IYCJ3 3p9gfwBAh7nYS2LWOS5YUTJXtutzw2MKVVi/u+s44VMcHbpSE1Xxp/cxIZGYIg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642682058; a=rsa-sha256; cv=none; b=SO8CQKlGko9rMmr+LJhk4Anm8aDVfWRHhPTDdQFbWfTt2j60wLz3idkjxEPjuVCQmMSxIY XkxkeyQVumF9Or5NML7XU+F7s2QHkU3hWpGpEHqcd+xKuNvNx3Jnj7Uki04HwCdsh6GqZP LQPe3TXGkw2lC0Fe2rQeLfIuIcbRluA86D+IM9I6S5FkxUOlWk8l6EouLU8jhcCFO1mgUi SGKz3z194i/iK00XGk4BcpLeyR3b0pn6JISosRgQvDn45hsgxaqgZ+rbA8j75Qv+w/3Hls 8jBf7uHpgzULQ/1GZVSUlKpPg6utqnXl5M+wyQT75UxCKbXVg/a03G2DL7FluA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.35 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: B2F123AA8E X-Spam-Score: -1.35 X-Migadu-Scanner: scn1.migadu.com X-TUID: Wy0e5qoXqSF8 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