Re: [PATCH] test: add simple tests for post-insert hook
authorJani Nikula <jani@nikula.org>
Tue, 28 Oct 2014 17:29:32 +0000 (19:29 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:44 +0000 (10:05 -0800)
69/421b891994da6dd92cc33d247a7b0bf0794438 [new file with mode: 0644]

diff --git a/69/421b891994da6dd92cc33d247a7b0bf0794438 b/69/421b891994da6dd92cc33d247a7b0bf0794438
new file mode 100644 (file)
index 0000000..5442016
--- /dev/null
@@ -0,0 +1,140 @@
+Return-Path: <jani@nikula.org>\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 CCD1F431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:29:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 gPp1BXbXPFtV for <notmuch@notmuchmail.org>;\r
+       Tue, 28 Oct 2014 10:29:36 -0700 (PDT)\r
+Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
+       [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B3B73431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:29:36 -0700 (PDT)\r
+Received: by mail-wi0-f174.google.com with SMTP id q5so10054073wiv.7\r
+       for <notmuch@notmuchmail.org>; Tue, 28 Oct 2014 10:29:35 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:subject:in-reply-to:references\r
+       :user-agent:date:message-id:mime-version:content-type;\r
+       bh=UGlu9o3WzLVa5twtdn1W0xdcNxMaLM2pnwBmcg/mAh0=;\r
+       b=U+HZtQ/+n8QlxnS8DIrvD3yXDSk3am2kqBiFCmMUy+f4LqX0DF4lBa77MbTGNE5DX7\r
+       ThNxmp+aqEa4jFWtcbE9cYWH8+jSejOCmET/JJlwUdB6erPvPimDviMv+COmQ5c+D4jA\r
+       AcmxYIcsvbnjCSROwiOIIWsyEeskDzb0M2BIawDGqrJUtSHUqATgOjhy66gUFAhuvcxr\r
+       zu9+f85xAG6y8OhHwszLMt7EPML0gXshDuX4a6Wn33PXUL048Wog8Bh6MH8XThGDAC5k\r
+       xGllhiC5TsHXucHwdcCypQAbijvh7x1GX/rkg2tuRaqiAMXjpUgbnfX2pLTENc5JuH/A\r
+       fQSQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnaGGhTUvMZLrbNRBuBAnbgkrpANiW+7JJ3SFLKg5MQXLr4Iur+fEd+a84edrmZzP6nTrl5\r
+X-Received: by 10.194.143.7 with SMTP id sa7mr6176524wjb.110.1414517375318;\r
+       Tue, 28 Oct 2014 10:29:35 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36d-48.dhcp.inet.fi.\r
+       [88.195.109.48])\r
+       by mx.google.com with ESMTPSA id vm6sm2544860wjc.16.2014.10.28.10.29.33\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Tue, 28 Oct 2014 10:29:34 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] test: add simple tests for post-insert hook\r
+In-Reply-To: <1413616955-27612-1-git-send-email-david@tethera.net>\r
+References:\r
+ <27c7ada91f96deda6e51732e0397bffd2ef2ab42.1411914914.git.jani@nikula.org>\r
+       <1413616955-27612-1-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.18.2+148~g0318cd3 (http://notmuchmail.org) Emacs/24.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 28 Oct 2014 19:29:32 +0200\r
+Message-ID: <87ppdcnlvn.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Tue, 28 Oct 2014 17:29:45 -0000\r
+\r
+On Sat, 18 Oct 2014, David Bremner <david@tethera.net> wrote:\r
+> Most of the existing tests for pre/post-new hook don't seem to apply.\r
+> ---\r
+>  test/T400-hooks.sh | 18 ++++++++++++++++++\r
+>  1 file changed, 18 insertions(+)\r
+>\r
+> diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh\r
+> index 77e8569..e741211 100755\r
+> --- a/test/T400-hooks.sh\r
+> +++ b/test/T400-hooks.sh\r
+> @@ -30,6 +30,8 @@ rm_hooks () {\r
+>  \r
+>  # add a message to generate mail dir and database\r
+>  add_message\r
+> +# create maildir structure for notmuch-insert\r
+> +mkdir -p "$MAIL_DIR"/{cur,new,tmp}\r
+>  \r
+>  test_begin_subtest "pre-new is run"\r
+>  rm_hooks\r
+> @@ -45,6 +47,16 @@ create_echo_hook "post-new" expected output\r
+>  notmuch new > /dev/null\r
+>  test_expect_equal_file expected output\r
+>  \r
+> +test_begin_subtest "post-insert hook is run"\r
+> +rm_hooks\r
+> +generate_message\r
+> +create_echo_hook "post-insert" expected output\r
+> +echo $gen_msg_filename\r
+> +cat output\r
+\r
+I presume the two lines above...\r
+\r
+> +notmuch insert < "$gen_msg_filename"\r
+> +echo $?\r
+\r
+...and this line are leftover debug messages?\r
+\r
+Otherwise LGTM. I guess this could be expanded with a subtest checking\r
+that the hook does not get run on errors, and does get run with some\r
+errors that are ignored with --keep.\r
+\r
+BR,\r
+Jani.\r
+\r
+> +test_expect_equal_file expected output\r
+> +\r
+>  test_begin_subtest "pre-new is run before post-new"\r
+>  rm_hooks\r
+>  generate_message\r
+> @@ -82,6 +94,12 @@ test_expect_equal_file expected output\r
+>  # depends on the previous subtest leaving broken hook behind\r
+>  test_expect_code 1 "post-new non-zero exit status (notmuch status)" "notmuch new"\r
+>  \r
+> +rm_hooks\r
+> +generate_message\r
+> +create_failing_hook "post-insert"\r
+> +test_expect_success "post-insert hook does not affect insert status" \\r
+> +    "notmuch insert < \"$gen_msg_filename\" > /dev/null"\r
+> +\r
+>  # test_begin_subtest "hook without executable permissions"\r
+>  rm_hooks\r
+>  mkdir -p ${HOOK_DIR}\r
+> -- \r
+> 2.1.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r