[PATCH v3 3/5] test: Update helper functions
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 10 Jun 2010 06:48:02 +0000 (08:48 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:08 +0000 (09:37 -0800)
cd/de6323417d7aa06b67005378d53411134a294a [new file with mode: 0644]

diff --git a/cd/de6323417d7aa06b67005378d53411134a294a b/cd/de6323417d7aa06b67005378d53411134a294a
new file mode 100644 (file)
index 0000000..fefc535
--- /dev/null
@@ -0,0 +1,167 @@
+Return-Path: <sojkam1@fel.cvut.cz>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B76B6418C25\r
+       for <notmuch@notmuchmail.org>; Wed,  9 Jun 2010 23:48:50 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 44G3za31DQta for <notmuch@notmuchmail.org>;\r
+       Wed,  9 Jun 2010 23:48:35 -0700 (PDT)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id 59F2F4196F0\r
+       for <notmuch@notmuchmail.org>; Wed,  9 Jun 2010 23:48:35 -0700 (PDT)\r
+Received: from localhost (unknown [192.168.200.4])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id A48C119F33D8;\r
+       Thu, 10 Jun 2010 08:48:34 +0200 (CEST)\r
+X-Virus-Scanned: IMAP AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+       by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
+       port 10044)\r
+       with ESMTP id kKrIc4EXjRKi; Thu, 10 Jun 2010 08:48:33 +0200 (CEST)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id 7D81A19F35E2;\r
+       Thu, 10 Jun 2010 08:48:32 +0200 (CEST)\r
+Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30])\r
+       (Authenticated sender: sojkam1)\r
+       by imap.feld.cvut.cz (Postfix) with ESMTPSA id 743DE15C062;\r
+       Thu, 10 Jun 2010 08:48:32 +0200 (CEST)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
+       (envelope-from <sojkam1@fel.cvut.cz>)\r
+       id 1OMbZ2-0000Jb-65; Thu, 10 Jun 2010 08:48:32 +0200\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 3/5] test: Update helper functions\r
+Date: Thu, 10 Jun 2010 08:48:02 +0200\r
+Message-Id: <1276152484-1164-4-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 1.7.1.3.g75e44\r
+In-Reply-To: <1276152484-1164-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1276152484-1164-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Jun 2010 06:48:52 -0000\r
+\r
+Modify the helper functions to work with git-based test suite i.e.\r
+1) Quote arguments where it is necessary.\r
+2) Do not use $NOTMUCH. It is equal to "notmuch" since $PATH is set to\r
+   the build tree.\r
+3) Modify pass_if_equal to fit into the git-based test suite.\r
+\r
+Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
+---\r
+ test/test-lib.sh |   33 +++++++++++++--------------------\r
+ 1 files changed, 13 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 7684c2e..d045820 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -221,10 +221,10 @@ remove_cr () {\r
+ increment_mtime_amount=0\r
+ increment_mtime ()\r
+ {\r
+-    dir=$1\r
++    dir="$1"\r
\r
+     increment_mtime_amount=$((increment_mtime_amount + 1))\r
+-    touch -d "+${increment_mtime_amount} seconds" $dir\r
++    touch -d "+${increment_mtime_amount} seconds" "$dir"\r
+ }\r
\r
+ # Generate a new message in the mail directory, with a unique message\r
+@@ -291,7 +291,7 @@ generate_message ()\r
+       gen_msg_filename="${MAIL_DIR}/$gen_msg_name"\r
+     else\r
+       gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"\r
+-      mkdir -p $(dirname $gen_msg_filename)\r
++      mkdir -p "$(dirname "$gen_msg_filename")"\r
+     fi\r
\r
+     if [ -z "${template[body]}" ]; then\r
+@@ -346,7 +346,7 @@ ${additional_headers}"\r
+     fi\r
\r
\r
+-cat <<EOF >$gen_msg_filename\r
++cat <<EOF >"$gen_msg_filename"\r
+ From: ${template[from]}\r
+ To: ${template[to]}\r
+ Message-Id: <${gen_msg_id}>\r
+@@ -357,7 +357,7 @@ ${template[body]}\r
+ EOF\r
\r
+     # Ensure that the mtime of the containing directory is updated\r
+-    increment_mtime $(dirname ${gen_msg_filename})\r
++    increment_mtime "$(dirname "${gen_msg_filename}")"\r
+ }\r
\r
+ # Generate a new message and add it to the index.\r
+@@ -366,41 +366,34 @@ EOF\r
+ # are also supported here, so see that function for details.\r
+ add_message ()\r
+ {\r
+-    generate_message "$@"\r
+-\r
+-    $NOTMUCH new > /dev/null\r
++    generate_message "$@" &&\r
++    notmuch new > /dev/null\r
+ }\r
\r
+-tests=0\r
+-test_failures=0\r
+-\r
+ pass_if_equal ()\r
+ {\r
+     output=$1\r
+     expected=$2\r
\r
+-    tests=$((tests + 1))\r
+-\r
+     if [ "$output" = "$expected" ]; then\r
+-      echo "  PASS"\r
++      true\r
+     else\r
+-      echo "  FAIL"\r
+-      testname=test-$(printf "%03d" $tests)\r
++      testname=$this_test.$test_count\r
+       echo "$expected" > $testname.expected\r
+       echo "$output" > $testname.output\r
+-      diff -u $testname.expected $testname.output || true\r
+-      test_failures=$((test_failures + 1))\r
++      diff -u $testname.expected $testname.output\r
++      false\r
+     fi\r
+ }\r
\r
+ TEST_DIR=$(pwd)/test.$$\r
+ MAIL_DIR=${TEST_DIR}/mail\r
+ export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config\r
+-NOTMUCH=$(find_notmuch_binary $(pwd))\r
++NOTMUCH=notmuch\r
\r
+ NOTMUCH_NEW ()\r
+ {\r
+-    $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
++    notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
+ }\r
\r
+ notmuch_search_sanitize ()\r
+-- \r
+1.7.1.3.g75e44\r
+\r