unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jameson Graef Rollins <jrollins@finestructure.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 05/11] test: new test-lib function to test for equality between files
Date: Wed, 25 May 2011 18:01:14 -0700	[thread overview]
Message-ID: <1306371680-19441-6-git-send-email-jrollins@finestructure.net> (raw)
In-Reply-To: <1306371680-19441-1-git-send-email-jrollins@finestructure.net>

We need to be able to test for the presence of a newline at the end of
output.  There's no good way to capture trailing newlines in bash, so
redirecting output to a file is the next best thing.  This new
function should be used when testing for output that is expected to
have trailing newlines.

The next commit will demonstrate the use of this.
---
 test/test-lib.sh |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index f536172..9e2e0b5 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -441,6 +441,29 @@ test_expect_equal ()
     fi
 }
 
+test_expect_equal_file ()
+{
+	exec 1>&6 2>&7		# Restore stdout and stderr
+	inside_subtest=
+	test "$#" = 3 && { prereq=$1; shift; } || prereq=
+	test "$#" = 2 ||
+	error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
+
+	output="$1"
+	expected="$2"
+	if ! test_skip "$@"
+	then
+		if diff -q "$expected" "$output" >/dev/null ; then
+			test_ok_ "$test_subtest_name"
+		else
+			testname=$this_test.$test_count
+			mv "$output" $testname.output
+			mv "$expected" $testname.expected
+			test_failure_ "$test_subtest_name" "$(diff -u $testname.expected $testname.output)"
+		fi
+    fi
+}
+
 test_expect_equal_failure ()
 {
 	exec 1>&6 2>&7		# Restore stdout and stderr
-- 
1.7.4.4

  parent reply	other threads:[~2011-05-26  1:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26  1:01 New crypto patch series Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 01/11] Simplify reply_part function to eliminate redundant code paths Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 02/11] Integrate reply_part_content function into reply_part function Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 03/11] Use empty strings instead of NULL in format_reply structure Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 04/11] Break up format->part function into part_start and part_content functions Jameson Graef Rollins
2011-05-26  1:01 ` Jameson Graef Rollins [this message]
2011-05-26  1:01 ` [PATCH 06/11] test: add notmuch_show_sanitize_all function that is a little more aggressive Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 07/11] test: add crypto tests for signature verification and decryption Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 08/11] Add signature verification of PGP/MIME-signed parts with --verify Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 09/11] Add decryption of PGP/MIME-encrypted parts with --decrypt Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 10/11] emacs: Add support for PGP/MIME verification/decryption Jameson Graef Rollins
2011-05-26  1:01 ` [PATCH 11/11] tag signed/encrypted during notmuch new Jameson Graef Rollins
2011-05-27 10:27 ` normalizing part numbering across PGP/MIME processing Jameson Graef Rollins
2011-05-27 10:27   ` [PATCH 1/4] Do not replace multipart/signed part with content part when doing verification Jameson Graef Rollins
2011-05-27 10:27     ` [PATCH 2/4] Render all parts of multipart/encrypted when decrypting Jameson Graef Rollins
2011-05-27 10:27       ` [PATCH 3/4] emacs: Do not attempt to render arbitrary application parts Jameson Graef Rollins
2011-05-27 10:27         ` [PATCH 4/4] emacs: Give mutlipart/{signed, encrypted} their own part handler Jameson Graef Rollins
2011-05-27 18:52           ` [PATCH] " Jameson Graef Rollins
2011-05-27 18:34   ` normalizing part numbering across PGP/MIME processing Daniel Kahn Gillmor
2011-05-28  0:53   ` Carl Worth
2011-05-28 21:31     ` Jameson Graef Rollins
2011-06-03 21:34       ` Carl Worth
2011-06-03 23:03     ` [PATCH] Always return the empty string if decryption tries to demand a password Daniel Kahn Gillmor
2011-06-03 23:15       ` Carl Worth
2011-06-03 23:37         ` Daniel Kahn Gillmor
2011-06-03 23:57           ` [PATCH] Use stock GMimeSession by default Daniel Kahn Gillmor
2011-06-03 23:57             ` Daniel Kahn Gillmor
2011-06-04  1:11               ` Carl Worth

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=1306371680-19441-6-git-send-email-jrollins@finestructure.net \
    --to=jrollins@finestructure.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).