X-Envelope-From: notmuch-bounces@notmuchmail.org  Sat Apr  4 07:20:18 2026
Return-Path: <notmuch-bounces@notmuchmail.org>
X-Original-To: nmbug@yantan.tethera.net
Delivered-To: nmbug@yantan.tethera.net
Received: from yantan.tethera.net (localhost [127.0.0.1])
	by mail.notmuchmail.org (Postfix) with ESMTP id B82CF60509;
	Sat,  4 Apr 2026 07:20:18 +0000 (UTC)
Received: from phubs.tethera.net (phubs.tethera.net [192.99.9.157])
	by mail.notmuchmail.org (Postfix) with ESMTPS id 3872B5F813
	for <notmuch@notmuchmail.org>; Sat,  4 Apr 2026 07:20:15 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tethera.net;
 i=@tethera.net; q=dns/txt; s=2024; t=1775287213; h=from : to : subject
 : in-reply-to : references : date : message-id : mime-version :
 content-type : from; bh=5CU50bqrNNDwhlg8hv3Eab37l+QZbO9lIapqhAiQQ1E=;
 b=duxx87WgnZqpYp1iUbc3DmyFnQ7DH72pHRpfyE8nu/ZV3B2IQqDuHzsti8XJQOLD87XZt
 STWgzroKr6r8QmVW4RnmAk0IZvEMhdvwGB3uwRu4TLDgHdkUXvFg2os0sl/OpOHp0udGJ8e
 VstrYm4dG2lRJk7/KKYDhJlNL3cIGGJ794W3JL94gZO6czlV0O3rh0MF8+5MAnfMbpqwqFA
 8nPDdu45wOdxoHDpLrT1u9EQfXFP7OVogJ0V6t/w6ocJTnGodO1sXuLalGXl6byFYztkOSA
 9sCzJOEuU+9XIb/dFyNDZtVk7wY3BFok6eYfiv2JOpBpxh2h1+ZKORde7CZA==
Received: from tethera.net (M111108027213.v4.enabler.ne.jp [111.108.27.213])
	by phubs.tethera.net (Postfix) with ESMTPS id B31AC1800F7;
	Sat, 04 Apr 2026 04:20:12 -0300 (ADT)
Received: (nullmailer pid 1035071 invoked by uid 1000);
	Sat, 04 Apr 2026 07:20:10 -0000
From: David Bremner <david@tethera.net>
To: Anton Khirnov <anton@khirnov.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH v4 3/6] test: add tests for attachment filtering
In-Reply-To: <20260307160342.16482-4-anton@khirnov.net>
References: <20260307160342.16482-1-anton@khirnov.net>
 <20260307160342.16482-4-anton@khirnov.net>
Date: Sat, 04 Apr 2026 16:20:10 +0900
Message-ID: <875x679oph.fsf@tethera.net>
MIME-Version: 1.0
Message-ID-Hash: 5KYAZXMMBBNFZLEAWIN3V6XUAVAT5UEL
X-Message-ID-Hash: 5KYAZXMMBBNFZLEAWIN3V6XUAVAT5UEL
X-MailFrom: david@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." <notmuch.notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Owner: <mailto:notmuch-owner@notmuchmail.org>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Subscribe: <mailto:notmuch-join@notmuchmail.org>
List-Unsubscribe: <mailto:notmuch-leave@notmuchmail.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit


A sentence or so about the overall goal here (e.g. excluding isolation)
would improve the commit message.

As mentioned in reply to patch 1, some trivial tests of the modified
python bindings is needed. I suspect it's probably simplest to add to
bindings/python-cffi/tests/test_config.py, but I don't mind either way.


Anton Khirnov <anton@khirnov.net> writes:

> ---
>  test/T681-index-filter.sh | 84 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
>  create mode 100755 test/T681-index-filter.sh
>
> diff --git a/test/T681-index-filter.sh b/test/T681-index-filter.sh
> new file mode 100755
> index 00000000..6ef7b9e4
> --- /dev/null
> +++ b/test/T681-index-filter.sh
> @@ -0,0 +1,84 @@
> +#!/usr/bin/env bash
> +test_description="indexing attachment with a filter"

I would suggest "indexing attachments with an external filter"

> +. $(dirname "$0")/test-lib.sh || exit 1
> +
> +notmuch config set index.as_text ".*"
> +
> +cat <<EOF > $MAIL_DIR/attachment-empty.eml
> +From: example@example.net
> +To: example@example.com
> +Subject: zero-size attachment
> +Date: Sun, 09 Feb 2025 12:33:43 +0000
> +Message-ID: <177064044971.16863.empty@localhost>
> +MIME-Version: 1.0
> +Content-Type: text/plain
> +Content-Disposition: attachment; filename=foo.txt
> +Content-Transfer-Encoding: base64
> +
> +EOF
> +
> +MSG_FILE_LARGE=${MAIL_DIR}/attachment-large.eml
> +
> +cat <<EOF > $MSG_FILE_LARGE
> +From: example@example.net
> +To: example@example.com
> +Subject: large attachment
> +Date: Sun, 09 Feb 2025 12:33:44 +0000
> +Message-ID: <177064044971.16863.large@localhost>
> +MIME-Version: 1.0
> +Content-Type: text/plain
> +Content-Disposition: attachment; filename=foo.txt
> +Content-Transfer-Encoding: base64
> +
> +EOF
> +
> +{ for i in $(seq 65536); do echo $i; done } | base64 >> $MSG_FILE_LARGE
> +
> +notmuch new
> +
> +cat <<EOF > EXPECTED
> +thread:XXX   2025-02-09 [1/1] example@example.net; large attachment (attachment inbox unread)
> +thread:XXX   2025-02-09 [1/1] example@example.net; zero-size attachment (attachment inbox unread)
> +EOF
> +
> +test_begin_subtest 'input ignored'
> +notmuch config set index.filter "/bin/sh -c 'echo secretstring'"
> +notmuch reindex '*'
> +notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest 'input consumed'
> +notmuch config set index.filter "/bin/sh -c 'cat - > /dev/null; echo secretstring'"
> +notmuch reindex '*'
> +notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
> +test_expect_equal_file EXPECTED OUTPUT

I'm curious here, how does a failure manifest?

> +
> +test_begin_subtest 'interleaved IO'
> +# this filter interleaves reads of increasingly large weird-sized blocks
> +# with writes
> +notmuch config set index.filter '/bin/sh -c "
> +bs=53;
> +while true; do
> +    dd bs=\$bs count=1 2>&1 >/dev/null | grep -q \"^0+0 records in$\" >&2 && break;
> +    echo \$bs;
> +    bs=\$((\$bs+48));
> +done;
> +echo secretstring;
> +"'
> +notmuch reindex '*'
> +notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
> +test_expect_equal_file EXPECTED OUTPUT
> +
> +test_begin_subtest 'exit failure'
> +notmuch config set index.filter "/bin/sh -c 'echo secretstring; exit 1'"
> +notmuch reindex '*'
> +notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
> +test_expect_equal_file /dev/null OUTPUT
> +

Is there some positive indication of error we can test for here? I have
found that testing for empty output tends to hide things failing in
unanticipated ways.

> +test_begin_subtest 'exit signal'
> +notmuch config set index.filter "/bin/sh -c 'echo secretstring; kill -ABRT \$\$'"
> +notmuch reindex '*'
> +notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
> +test_expect_equal_file /dev/null OUTPUT

Same question here.
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org
