Re: [PATCH v4 3/6] test: add tests for attachment filtering

Subject: Re: [PATCH v4 3/6] test: add tests for attachment filtering

Date: Sat, 18 Apr 2026 08:45:12 +0200

To: notmuch@notmuchmail.org, David Bremner

Cc:

From: Anton Khirnov


Quoting David Bremner (2026-04-04 09:20:10)
> > +
> > +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?

The test hanging while waiting for the pipe to become writeable is a
typical failure I'd expect here.

> 
> > +
> > +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.

I don't see how. We do not want a filter failure to abort the whole
indexing run (imagine someone sent you a corrupted zip file) and there's
no other channel for propagating filter errors to the library caller.

There is _notmuch_database_log(), but AFAIU the log contents are not
made available to the user (IIRC we discussed that briefly on IRC last
year). That could of course be changed, but that seems beyond the scope
of this patchset to me.

Cheers,
-- 
Anton Khirnov
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: