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