---
 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..e4d75716
--- /dev/null
+++ b/test/T681-index-filter.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+test_description="indexing attachment with a filter"
+. $(dirname "$0")/test-lib.sh || exit 1
+
+notmuch config set index.as_text ".*"
+
+cat <<EOF > $MAIL_DIR/attachment-empty.eml
+From: [email protected]
+To: [email protected]
+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: [email protected]
+To: [email protected]
+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] [email protected]; large attachment 
(attachment inbox unread)
+thread:XXX   2025-02-09 [1/1] [email protected]; zero-size attachment 
(attachment inbox unread)
+EOF
+
+test_begin_subtest 'input ignored'
+notmuch config set index.filter "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 "cat - > /dev/null; echo secretstring"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest 'interleaved IO'
+# this filter interleaves reads of increasingly large weird-sized blocks
+# with writes
+notmuch config set index.filter "
+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 "echo secretstring; exit 1"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest 'exit signal'
+notmuch config set index.filter "echo secretstring; kill -ABRT \$\$"
+notmuch reindex '*'
+notmuch search "secretstring" | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_done
-- 
2.47.3

_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to