Blob Blame History Raw
From 026297aa4fb06f99f8234bdba33bc6dc628be705 Mon Sep 17 00:00:00 2001
Message-ID: <026297aa4fb06f99f8234bdba33bc6dc628be705.1685017635.git.git@grubix.eu>
In-Reply-To: <9a28b8b3c2b7c76cb44a4afa837645677097fc9f.1685017635.git.git@grubix.eu>
References: <9a28b8b3c2b7c76cb44a4afa837645677097fc9f.1685017635.git.git@grubix.eu>
From: Michael J Gruber <git@grubix.eu>
Date: Thu, 25 May 2023 13:49:01 +0200
Subject: [PATCH 2/2] test: use NOTMUCH_NEW consistently

The test suite provides `NOTMUCH_NEW ()` primarily as a way to sanitize
the output of `notmuch new`. As a side effect, this allows to pass
options to each `notmuch new` in the test suite which is used via
`NOTMUCH_NEW`.

Convert the test suite to use `NOTMUCH_NEW` in all instances. In order
to capture the exit code without (and receive the raw output), we
convert the existing `NOTMUCH_NEW` to `NOTMUCH_NEW_SANITIZE` which
sanitizes the output and returns the exit code of the filter as before.
---
 test/T030-config.sh                    |  4 +-
 test/T035-read-config.sh               |  4 +-
 test/T050-new.sh                       | 92 +++++++++++++-------------
 test/T051-new-renames.sh               |  6 +-
 test/T055-path-config.sh               | 10 +--
 test/T070-insert.sh                    |  2 +-
 test/T080-search.sh                    |  2 +-
 test/T081-sexpr-search.sh              |  2 +-
 test/T095-address.sh                   |  2 +-
 test/T100-search-by-folder.sh          |  6 +-
 test/T140-excludes.sh                  |  4 +-
 test/T190-multipart.sh                 |  6 +-
 test/T210-raw.sh                       |  2 +-
 test/T240-dump-restore.sh              |  4 +-
 test/T260-thread-order.sh              |  6 +-
 test/T270-author-order.sh              | 10 +--
 test/T290-long-id.sh                   |  6 +-
 test/T310-emacs.sh                     |  2 +-
 test/T320-emacs-large-search-buffer.sh |  2 +-
 test/T340-maildir-sync.sh              | 16 ++---
 test/T357-index-decryption.sh          |  4 +-
 test/T370-search-folder-coherence.sh   |  8 +--
 test/T380-atomicity.sh                 |  2 +-
 test/T385-transactions.sh              |  2 +-
 test/T395-ruby.sh                      |  2 +-
 test/T400-hooks.sh                     | 20 +++---
 test/T455-emacs-charsets.sh            |  2 +-
 test/T465-emacs-unthreaded.sh          |  2 +-
 test/T470-missing-headers.sh           |  2 +-
 test/T530-upgrade.sh                   | 10 +--
 test/T550-db-features.sh               |  4 +-
 test/T560-lib-error.sh                 |  2 +-
 test/T562-lib-database.sh              |  2 +-
 test/T563-lib-directory.sh             |  2 +-
 test/T564-lib-query.sh                 |  2 +-
 test/T566-lib-message.sh               |  2 +-
 test/T568-lib-thread.sh                |  2 +-
 test/T592-thread-breakage.sh           | 14 ++--
 test/T720-lib-lifetime.sh              |  2 +-
 test/T750-gzip.sh                      | 12 ++--
 test/test-lib-emacs.sh                 |  4 +-
 test/test-lib.sh                       |  6 +-
 42 files changed, 150 insertions(+), 146 deletions(-)

diff --git a/test/T030-config.sh b/test/T030-config.sh
index 43bbce31..754d5cbf 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -156,7 +156,7 @@ test_expect_equal "${path} ${count}" \
 		  "CWD/home/Maildir 52"
 
 test_begin_subtest "Add config to database"
-notmuch new
+NOTMUCH_NEW
 key=g${RANDOM}.m${RANDOM}
 value=${RANDOM}
 notmuch config set --database ${key} ${value}
@@ -168,7 +168,7 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Roundtrip config to/from database"
-notmuch new
+NOTMUCH_NEW
 key=g${RANDOM}.m${RANDOM}
 value=${RANDOM}
 notmuch config set --database ${key} ${value}
diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index ac0f420b..dec09668 100755
--- a/test/T035-read-config.sh
+++ b/test/T035-read-config.sh
@@ -462,14 +462,14 @@ test_expect_equal "52" "$output"
 test_begin_subtest "run notmuch-new (xdg)"
 xdg_config
 generate_message
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 restore_config
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "run notmuch-new (xdg + profile)"
 xdg_config ${RANDOM}
 generate_message
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 restore_config
 test_expect_equal "$output" "Added 1 new message to the database."
 
diff --git a/test/T050-new.sh b/test/T050-new.sh
index 6791f87c..0f7c4eac 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -3,38 +3,38 @@ test_description='"notmuch new" in several variations'
 . $(dirname "$0")/test-lib.sh || exit 1
 
 test_begin_subtest "No new messages"
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "No new mail."
 
 
 test_begin_subtest "Single new message"
 generate_message
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Single message (full-scan)"
 generate_message
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Multiple new messages"
 generate_message
 generate_message
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 2 new messages to the database."
 
 test_begin_subtest "Multiple new messages (full-scan)"
 generate_message
 generate_message
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" "Added 2 new messages to the database."
 
 test_begin_subtest "No new messages (non-empty DB)"
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "No new mail."
 
 test_begin_subtest "No new messages (full-scan)"
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" "No new mail."
 
 test_begin_subtest "New directories"
@@ -43,7 +43,7 @@ mkdir "${MAIL_DIR}"/def
 mkdir "${MAIL_DIR}"/ghi
 generate_message [dir]=def
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 
@@ -54,7 +54,7 @@ mv "${MAIL_DIR}"/ghi "${MAIL_DIR}"/abc
 rm "${MAIL_DIR}"/def/*
 generate_message [dir]=abc
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 
@@ -64,18 +64,18 @@ generate_message
 tmp_msg_filename=tmp/"$gen_msg_filename"
 mkdir -p "$(dirname "$tmp_msg_filename")"
 mv "$gen_msg_filename" "$tmp_msg_filename"
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 mv "$tmp_msg_filename" "$gen_msg_filename"
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 
 test_begin_subtest "Renamed message"
 
 generate_message
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 mv "$gen_msg_filename" "${gen_msg_filename}"-renamed
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "(D) add_files, pass 2: queuing passed file ${gen_msg_filename} for deletion from database
 No new mail. Detected 1 file rename."
 
@@ -83,7 +83,7 @@ No new mail. Detected 1 file rename."
 test_begin_subtest "Deleted message"
 
 rm "${gen_msg_filename}"-renamed
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "(D) add_files, pass 3: queuing leftover file ${gen_msg_filename}-renamed for deletion from database
 No new mail. Removed 1 message."
 
@@ -95,11 +95,11 @@ generate_message [dir]=dir
 generate_message [dir]=dir
 generate_message [dir]=dir
 
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 mv "${MAIL_DIR}"/dir "${MAIL_DIR}"/dir-renamed
 
-output=$(NOTMUCH_NEW --debug --full-scan)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan)
 test_expect_equal "$output" "(D) add_files, pass 2: queuing passed directory ${MAIL_DIR}/dir for deletion from database
 No new mail. Detected 3 file renames."
 
@@ -107,7 +107,7 @@ No new mail. Detected 3 file renames."
 test_begin_subtest "Deleted directory"
 rm -rf "${MAIL_DIR}"/dir-renamed
 
-output=$(NOTMUCH_NEW --debug --full-scan)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan)
 test_expect_equal "$output" "(D) add_files, pass 2: queuing passed directory ${MAIL_DIR}/dir-renamed for deletion from database
 No new mail. Removed 3 messages."
 
@@ -118,7 +118,7 @@ generate_message [dir]=zzz
 generate_message [dir]=zzz
 generate_message [dir]=zzz
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 3 new messages to the database."
 
 
@@ -126,7 +126,7 @@ test_begin_subtest "Deleted directory (end of list)"
 
 rm -rf "${MAIL_DIR}"/zzz
 
-output=$(NOTMUCH_NEW --debug --full-scan)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan)
 test_expect_equal "$output" "(D) add_files, pass 3: queuing leftover directory ${MAIL_DIR}/zzz for deletion from database
 No new mail. Removed 3 messages."
 
@@ -139,7 +139,7 @@ mv "${MAIL_DIR}" "${TMP_DIRECTORY}"/actual_maildir
 mkdir "${MAIL_DIR}"
 ln -s "${TMP_DIRECTORY}"/actual_maildir "${MAIL_DIR}"/symlink
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 
@@ -149,13 +149,13 @@ external_msg_filename="${TMP_DIRECTORY}"/external/"$(basename "$gen_msg_filename
 mkdir -p "$(dirname "$external_msg_filename")"
 mv "$gen_msg_filename" "$external_msg_filename"
 ln -s "$external_msg_filename" "$gen_msg_filename"
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 
 test_begin_subtest "Broken symlink aborts"
 ln -s does-not-exist "${MAIL_DIR}/broken"
-output=$(NOTMUCH_NEW --debug 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug 2>&1)
 test_expect_equal "$output" \
 "Error reading file ${MAIL_DIR}/broken: No such file or directory
 Note: A fatal error was encountered: Something went wrong trying to read or write a file
@@ -169,7 +169,7 @@ generate_message [dir]=two/levels
 generate_message [dir]=two/levels
 generate_message [dir]=two/levels
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 3 new messages to the database."
 
 
@@ -177,7 +177,7 @@ test_begin_subtest "Deleted two-level directory"
 
 rm -rf "${MAIL_DIR}"/two
 
-output=$(NOTMUCH_NEW --debug --full-scan)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan)
 test_expect_equal "$output" "(D) add_files, pass 3: queuing leftover directory ${MAIL_DIR}/two for deletion from database
 No new mail. Removed 3 messages."
 
@@ -187,7 +187,7 @@ generate_message [dir]=A
 generate_message [dir]=A/B
 generate_message [dir]=A/B/C
 
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 3 new messages to the database."
 
 test_begin_subtest "Support single-message mbox"
@@ -199,7 +199,7 @@ Subject: Test mbox message 1
 
 Body.
 EOF
-output=$(NOTMUCH_NEW --debug 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug 2>&1)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 # This test requires that notmuch new has been run at least once.
@@ -223,7 +223,7 @@ Subject: Test mbox message 2
 
 Body 2.
 EOF
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" \
 "Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
 Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
@@ -236,7 +236,7 @@ test_begin_subtest "Ignore files and directories specified in new.ignore"
 generate_message
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file
 touch "${MAIL_DIR}"/.git # change .git's mtime for notmuch new to rescan.
-NOTMUCH_NEW --debug 2>&1 | sort > OUTPUT
+NOTMUCH_NEW_SANITIZE --debug 2>&1 | sort > OUTPUT
 cat <<EOF > EXPECTED
 (D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.git
 (D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
@@ -251,16 +251,16 @@ test_expect_equal_file EXPECTED OUTPUT
 test_begin_subtest "Ignore files and directories specified in new.ignore (full-scan)"
 generate_message
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file
-NOTMUCH_NEW --debug --full-scan 2>&1 | sort > OUTPUT
+NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1 | sort > OUTPUT
 # reuse EXPECTED from previous test
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Ignore files and directories specified in new.ignore (multiple occurrences)"
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file
-notmuch new > /dev/null # ensure that files/folders will be printed in ASCII order.
+NOTMUCH_NEW > /dev/null # ensure that files/folders will be printed in ASCII order.
 mkdir -p "${MAIL_DIR}"/one/two/three/.git
 touch "${MAIL_DIR}"/{one,one/two,one/two/three}/ignored_file
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1 | sort)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1 | sort)
 test_expect_equal "$output" \
 "(D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.git
 (D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
@@ -282,12 +282,12 @@ No new mail."
 test_begin_subtest "Don't stop for ignored broken symlinks"
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file broken_link
 ln -s i_do_not_exist "${MAIL_DIR}"/broken_link
-output=$(NOTMUCH_NEW 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE 2>&1)
 test_expect_equal "$output" "No new mail."
 
 test_begin_subtest "Ignore files and directories specified in new.ignore (regexp)"
 notmuch config set new.ignore ".git" "/^bro.*ink\$/" "/ignored.*file/"
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1 | sort)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1 | sort)
 test_expect_equal "$output" \
 "(D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.git
 (D) add_files, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
@@ -308,7 +308,7 @@ test_expect_equal "$output" \
 No new mail."
 
 test_begin_subtest "Quiet: No new mail."
-output=$(NOTMUCH_NEW --quiet)
+output=$(NOTMUCH_NEW_SANITIZE --quiet)
 test_expect_equal "$output" ""
 
 test_begin_subtest "Quiet: new, removed and renamed messages."
@@ -319,21 +319,21 @@ notmuch search --format=text0 --output=files --limit=1 '*' | xargs -0 rm
 # moved
 mkdir "${MAIL_DIR}"/moved_messages
 notmuch search --format=text0 --output=files --offset=1 --limit=1 '*' | xargs -0 -I {} mv {} "${MAIL_DIR}"/moved_messages
-output=$(NOTMUCH_NEW --quiet)
+output=$(NOTMUCH_NEW_SANITIZE --quiet)
 test_expect_equal "$output" ""
 
 OLDCONFIG=$(notmuch config get new.tags)
 
 test_begin_subtest "Empty tags in new.tags are ignored"
 notmuch config set new.tags "foo;;bar"
-output=$(NOTMUCH_NEW --quiet 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --quiet 2>&1)
 test_expect_equal "$output" ""
 
 test_begin_subtest "leading/trailing whitespace in new.tags is ignored"
 # avoid complications with leading spaces and "notmuch config"
 sed -i 's/^tags=.*$/tags= fu bar ; ; bar /' notmuch-config
 add_message
-NOTMUCH_NEW --quiet
+NOTMUCH_NEW_SANITIZE --quiet
 notmuch dump id:$gen_msg_id | sed 's/ --.*$//' > OUTPUT
 cat <<EOF >EXPECTED
 #notmuch-dump batch-tag:3 config,properties,tags
@@ -343,17 +343,17 @@ test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Tags starting with '-' in new.tags are forbidden"
 notmuch config set new.tags "-foo;bar"
-output=$(NOTMUCH_NEW --debug 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug 2>&1)
 test_expect_equal "$output" "Error: tag '-foo' in new.tags: tag starting with '-' forbidden"
 
 test_begin_subtest "Invalid tags set exit code"
-test_expect_code 1 "NOTMUCH_NEW --debug 2>&1"
+test_expect_code 1 "NOTMUCH_NEW_SANITIZE --debug 2>&1"
 
 notmuch config set new.tags $OLDCONFIG
 
 test_begin_subtest ".notmuch only ignored at top level"
 generate_message '[dir]=foo/bar/.notmuch/cur' '[subject]="Do not ignore, very important"'
-NOTMUCH_NEW > OUTPUT
+NOTMUCH_NEW_SANITIZE > OUTPUT
 notmuch search subject:Do-not-ignore | notmuch_search_sanitize >> OUTPUT
 cat <<EOF > EXPECTED
 Added 1 new message to the database.
@@ -364,7 +364,7 @@ test_expect_equal_file EXPECTED OUTPUT
 test_begin_subtest "RFC822 group names are indexed"
 test_subtest_known_broken
 generate_message [to]="undisclosed-recipients:"
-NOTMUCH_NEW > OUTPUT
+NOTMUCH_NEW_SANITIZE > OUTPUT
 output=$(notmuch search --output=messages to:undisclosed-recipients)
 test_expect_equal "${output}" "${gen_msg_id}"
 
@@ -373,9 +373,9 @@ test_subtest_known_broken
 printf -v name 'z%.0s' {1..234}
 generate_message [dir]=$name
 NOTMUCH_NEW > OUTPUT
-notmuch new >> OUTPUT
+NOTMUCH_NEW >> OUTPUT
 rm -r ${MAIL_DIR}/${name}
-notmuch new >> OUTPUT
+NOTMUCH_NEW >> OUTPUT
 cat <<EOF > EXPECTED
 Added 1 new message to the database.
 No new mail.
@@ -385,7 +385,7 @@ test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Xapian exception: read only files"
 chmod u-w ${MAIL_DIR}/.notmuch/xapian/*.*
-output=$(NOTMUCH_NEW --debug 2>&1 | sed 's/: .*$//' )
+output=$(NOTMUCH_NEW_SANITIZE --debug 2>&1 | sed 's/: .*$//' )
 chmod u+w ${MAIL_DIR}/.notmuch/xapian/*.*
 test_expect_equal "$output" "A Xapian exception occurred opening database"
 
@@ -422,7 +422,7 @@ test_begin_subtest "Relative database path expanded in new"
 ln -s "$PWD/mail" home/Maildir
 notmuch config set database.path Maildir
 generate_message
-NOTMUCH_NEW > OUTPUT
+NOTMUCH_NEW_SANITIZE > OUTPUT
 cat <<EOF >EXPECTED
 Added 1 new message to the database.
 EOF
@@ -434,7 +434,7 @@ test_begin_subtest "Relative mail root (in db) expanded in new"
 ln -s "$PWD/mail" home/Maildir
 notmuch config set --database database.mail_root Maildir
 generate_message
-NOTMUCH_NEW > OUTPUT
+NOTMUCH_NEW_SANITIZE > OUTPUT
 cat <<EOF >EXPECTED
 Added 1 new message to the database.
 EOF
diff --git a/test/T051-new-renames.sh b/test/T051-new-renames.sh
index ebd06be1..c7ee432a 100755
--- a/test/T051-new-renames.sh
+++ b/test/T051-new-renames.sh
@@ -15,7 +15,7 @@ for i in {1..10}; do
 done
 
 test_begin_subtest "Index the messages, round $loop"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 20 new messages to the database."
 
 all_files=$(notmuch search --output=files \*)
@@ -23,12 +23,12 @@ count_foo=$(notmuch count folder:foo)
 
 test_begin_subtest "Rename folder"
 mv ${MAIL_DIR}/foo ${MAIL_DIR}/baz
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail. Detected $count_foo file renames."
 
 test_begin_subtest "Rename folder back"
 mv ${MAIL_DIR}/baz ${MAIL_DIR}/foo
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail. Detected $count_foo file renames."
 
 test_begin_subtest "Files remain the same"
diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 58c824a2..cf9d821d 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -166,19 +166,19 @@ EOF
     test_expect_equal_file_nonempty EXPECTED OUTPUT
 
     test_begin_subtest "use existing database ($config)"
-    output=$(notmuch new)
+    output=$(NOTMUCH_NEW)
     test_expect_equal "$output" 'No new mail.'
 
     test_begin_subtest "create database ($config)"
     rm -rf $DATABASE_PATH/{.notmuch,}/xapian
-    notmuch new
+    NOTMUCH_NEW
     output=$(notmuch count '*')
     test_expect_equal "$output" '52'
 
     test_begin_subtest "detect new files ($config)"
     generate_message
     generate_message
-    notmuch new
+    NOTMUCH_NEW
     output=$(notmuch count '*')
     test_expect_equal "$output" '54'
 
@@ -226,7 +226,7 @@ EOF
     test_begin_subtest "upgrade backup ($config)"
     features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
     xapian-metadata set $XAPIAN_PATH features "$features"
-    output=$(notmuch new | grep Welcome)
+    output=$(NOTMUCH_NEW | grep Welcome)
     test_expect_equal \
 	"$output" \
 	"Welcome to a new version of notmuch! Your database will now be upgraded."
@@ -354,7 +354,7 @@ EOF
 	   backup_database
 	   test_begin_subtest ".notmuch without xapian/ handled gracefully ($config)"
 	   rm -r $XAPIAN_PATH
-	   test_expect_success "notmuch new"
+	   test_expect_success "NOTMUCH_NEW"
 	   restore_database
 	   ;;
    esac
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 7d5f842d..2268e038 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -9,7 +9,7 @@ umask 022
 # Create directories and database before inserting.
 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
 mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 # We use generate_message to create the temporary message files.
 # They happen to be in the mail directory already but that is okay
diff --git a/test/T080-search.sh b/test/T080-search.sh
index a3f0dead..10bbbb7b 100755
--- a/test/T080-search.sh
+++ b/test/T080-search.sh
@@ -173,7 +173,7 @@ x y z
 
 --==-==--
 EOF
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 test_begin_subtest "headers do not have adjacent term positions"
 # Regression test for a bug where term positions for non-prefixed
diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh
index ce6b11b6..20999d66 100755
--- a/test/T081-sexpr-search.sh
+++ b/test/T081-sexpr-search.sh
@@ -625,7 +625,7 @@ notmuch config set search.exclude_tags deleted
 generate_message '[subject]="Not deleted"'
 not_deleted_id=$gen_msg_id
 generate_message '[subject]="Deleted"'
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 notmuch tag +deleted id:$gen_msg_id
 deleted_id=$gen_msg_id
 output=$(notmuch search --query=sexp '(subject deleted)' | notmuch_search_sanitize)
diff --git a/test/T095-address.sh b/test/T095-address.sh
index 8bb3627a..62b280b6 100755
--- a/test/T095-address.sh
+++ b/test/T095-address.sh
@@ -286,7 +286,7 @@ generate_message '[from]="foo.bar@example.com"'
 generate_message '[from]="Baz <foo.bar+baz@example.com>"'
 generate_message '[from]="Foo Bar <foo.bar+baz@example.com>"'
 generate_message '[from]="Baz <foo.bar+baz@example.com>"'
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 test_begin_subtest "--deduplicate=no --output=sender"
 notmuch address --deduplicate=no --output=sender from:example.com | sort >OUTPUT
diff --git a/test/T100-search-by-folder.sh b/test/T100-search-by-folder.sh
index b4f6294e..17cdf302 100755
--- a/test/T100-search-by-folder.sh
+++ b/test/T100-search-by-folder.sh
@@ -44,7 +44,7 @@ MAIL_DIR/duplicate/bad/news/msg-XXX"
 
 test_begin_subtest "After removing duplicate instance of matching path"
 rm -r "${MAIL_DIR}/bad/news"
-notmuch new
+NOTMUCH_NEW
 output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
 test_expect_equal "$output" ""
 
@@ -58,7 +58,7 @@ test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; B
 
 test_begin_subtest "After rename, old path returns nothing"
 mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
-notmuch new
+NOTMUCH_NEW
 output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
 test_expect_equal "$output" ""
 
@@ -72,7 +72,7 @@ add_email_corpus
 # add some more dupes
 cp $MAIL_DIR/foo/new/03:2, $MAIL_DIR/new
 cp $MAIL_DIR/bar/baz/05:2, $MAIL_DIR/foo
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 
 test_begin_subtest "folder: search"
 output=$(notmuch search --output=files folder:foo | notmuch_search_files_sanitize | sort)
diff --git a/test/T140-excludes.sh b/test/T140-excludes.sh
index e9cc9cb0..8965d2fb 100755
--- a/test/T140-excludes.sh
+++ b/test/T140-excludes.sh
@@ -19,7 +19,7 @@ generate_thread () {
 	gen_thread_msg_id[$i]=$gen_msg_id
 	parent_id=$gen_msg_id
     done
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
     # We cannot retrieve the thread_id until after we have run notmuch new.
     gen_thread_id=$(notmuch search --output=threads id:${gen_thread_msg_id[0]} 2>/dev/null)
 }
@@ -32,7 +32,7 @@ notmuch config set search.exclude_tags deleted
 generate_message '[subject]="Not deleted"'
 not_deleted_id=$gen_msg_id
 generate_message '[subject]="Deleted"'
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 notmuch tag +deleted id:$gen_msg_id
 deleted_id=$gen_msg_id
 output=$(notmuch search subject:deleted | notmuch_search_sanitize)
diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index cfe48ac5..c30ca5ca 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -138,7 +138,7 @@ This is an embedded message, with a multipart/alternative part.
 --==-=-==--
 EOF
 cat content_types >> ${MAIL_DIR}/odd_content_type
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 test_begin_subtest "--format=text --part=0, full message"
 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
@@ -723,7 +723,7 @@ Content-Type: text/plain; charset=UTF-8
 --==-==--
 EOF
 
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 cat_expected_head () {
         cat <<EOF
@@ -820,7 +820,7 @@ world
 --=-=-=--
 
 EOF
-NOTMUCH_NEW
+NOTMUCH_NEW_SANITIZE
 
 cat <<EOF > EXPECTED
 attachment
diff --git a/test/T210-raw.sh b/test/T210-raw.sh
index 44082028..01949b11 100755
--- a/test/T210-raw.sh
+++ b/test/T210-raw.sh
@@ -53,7 +53,7 @@ for pow in range(10,21):
         f.write(bytes(msg))
 EOF
 
-notmuch new --quiet
+NOTMUCH_NEW --quiet
 
 for pow in {10..20}; do
     printf -v size "%07d" $((2**$pow))
diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh
index a86f0fb7..88fec112 100755
--- a/test/T240-dump-restore.sh
+++ b/test/T240-dump-restore.sh
@@ -2,7 +2,7 @@
 test_description="\"notmuch dump\" and \"notmuch restore\""
 . $(dirname "$0")/test-lib.sh || exit 1
 
-NOTMUCH_NEW > /dev/null
+NOTMUCH_NEW_SANITIZE > /dev/null
 test_begin_subtest "dump header"
 cat <<EOF > EXPECTED
 #notmuch-dump batch-tag:3 config,properties,tags
@@ -12,7 +12,7 @@ test_expect_equal_file EXPECTED OUTPUT
 add_email_corpus
 
 test_begin_subtest "Dumping all tags"
-test_expect_success 'generate_message && notmuch new && notmuch dump > dump.expected'
+test_expect_success 'generate_message && NOTMUCH_NEW && notmuch dump > dump.expected'
 
 # The use of from:cworth is rather arbitrary: it matches some of the
 # email corpus' messages, but not all of them.
diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh
index fea61275..8c9e9585 100755
--- a/test/T260-thread-order.sh
+++ b/test/T260-thread-order.sh
@@ -21,7 +21,7 @@ for ((n = 0; n < 4; n++)); do
             [subject]=p$thread [from]=m$n
         thread=$((thread + 1))
     done <<< "$THREADS"
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
 done
 output=$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)
 expected=$(for ((i = 0; i < $nthreads; i++)); do
@@ -36,7 +36,7 @@ test_begin_subtest "Messages with all parents get linked in all delivery orders"
 # is currently broken because of the bug detailed in
 # id:8738h7kv2q.fsf@qmul.ac.uk.
 rm ${MAIL_DIR}/*
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 output=""
 expected=""
 for ((n = 0; n < 4; n++)); do
@@ -58,7 +58,7 @@ for ((n = 0; n < 4; n++)); do
             [subject]=p$thread [from]=m$n
         thread=$((thread + 1))
     done <<< "$THREADS"
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
 
     output="$output
 $(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)"
diff --git a/test/T270-author-order.sh b/test/T270-author-order.sh
index c28ecb02..aa1ee505 100755
--- a/test/T270-author-order.sh
+++ b/test/T270-author-order.sh
@@ -4,17 +4,17 @@ test_description="author reordering;"
 
 test_begin_subtest "Adding parent message"
 generate_message [body]=findme [id]=new-parent-id [subject]=author-reorder-threadtest '[from]="User <user@example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Adding initial child message"
 generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="User1 <user1@example.com>"' '[date]="Sat, 01 Jan 2000 12:01:00 -0000"'
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Adding second child message"
 generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="User2 <user2@example.com>"' '[date]="Sat, 01 Jan 2000 12:02:00 -0000"'
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Searching when all three messages match"
@@ -35,7 +35,7 @@ test_expect_equal "$output" "thread:XXX   2000-01-01 [1/3] User| User1, User2; a
 
 test_begin_subtest "Adding duplicate author"
 generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="User1 <user1@example.com>"' '[date]="Sat, 01 Jan 2000 12:03:00 -0000"'
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Searching when all four messages match"
@@ -44,7 +44,7 @@ test_expect_equal "$output" "thread:XXX   2000-01-01 [4/4] User, User1, User2; a
 
 test_begin_subtest "Adding non-monotonic child message"
 generate_message [body]=findme "[in-reply-to]=\<new-parent-id\>" [subject]=author-reorder-threadtest '[from]="User0 <user0@example.com>"' '[date]="Sat, 01 Jan 2000 11:00:00 -0000"'
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Searching non-monotonic messages (oldest-first)"
diff --git a/test/T290-long-id.sh b/test/T290-long-id.sh
index 5e3879f5..a73dc9e7 100755
--- a/test/T290-long-id.sh
+++ b/test/T290-long-id.sh
@@ -5,19 +5,19 @@ test_description="messages with ridiculously-long message IDs"
 test_begin_subtest "Referencing long ID before adding"
 generate_message '[subject]="Reference of ridiculously-long message ID"' \
 		 "[references]=\<abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\>"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Adding message with long ID"
 generate_message '[subject]="A ridiculously-long message ID"' \
 		 "[id]=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Referencing long ID after adding"
 generate_message '[subject]="Reply to ridiculously-long message ID"' \
 		 "[in-reply-to]=\<abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\>"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Ensure all messages were threaded together"
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 9d0df187..4e985c0e 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -258,7 +258,7 @@ EOF
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
 
diff --git a/test/T320-emacs-large-search-buffer.sh b/test/T320-emacs-large-search-buffer.sh
index 617985e6..bb7360ee 100755
--- a/test/T320-emacs-large-search-buffer.sh
+++ b/test/T320-emacs-large-search-buffer.sh
@@ -19,7 +19,7 @@ for i in $(seq 1 $n); do
   generate_message '[subject]="$x $i of $n"'
 done
 
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 test_begin_subtest "Ensure that emacs doesn't drop results"
 notmuch search '*' > EXPECTED
diff --git a/test/T340-maildir-sync.sh b/test/T340-maildir-sync.sh
index a697317f..0555d28f 100755
--- a/test/T340-maildir-sync.sh
+++ b/test/T340-maildir-sync.sh
@@ -15,7 +15,7 @@ output=$(notmuch search subject:"Adding S flag" | notmuch_search_sanitize)
 output+="
 "
 mv "${gen_msg_filename}" "${gen_msg_filename}S"
-output+=$(NOTMUCH_NEW)
+output+=$(NOTMUCH_NEW_SANITIZE)
 output+="
 "
 output+=$(notmuch search subject:"Adding S flag" | notmuch_search_sanitize)
@@ -65,7 +65,7 @@ test_begin_subtest "notmuch reply works with renamed file (without notmuch new)"
 test_expect_success 'notmuch reply id:${gen_msg_id}'
 
 test_begin_subtest "notmuch new detects no file rename after tag->flag synchronization"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail."
 
 test_begin_subtest "When read, message moved from new to cur"
@@ -75,7 +75,7 @@ output=$(cd "$MAIL_DIR/cur"; ls message-to-move*)
 test_expect_equal "$output" "message-to-move-to-cur:2,S"
 
 test_begin_subtest "No rename should be detected by notmuch new"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail."
 # (*) If notmuch new was not run we've got "Processed 1 file in almost
 # no time" here. The reason is that removing unread tag in a previous
@@ -114,7 +114,7 @@ output=$(notmuch search subject:"Removing S flag" | notmuch_search_sanitize)
 output+="
 "
 mv "${gen_msg_filename}" "${gen_msg_filename%S}"
-output+=$(NOTMUCH_NEW)
+output+=$(NOTMUCH_NEW_SANITIZE)
 output+="
 "
 output+=$(notmuch search subject:"Removing S flag" | notmuch_search_sanitize)
@@ -126,7 +126,7 @@ test_begin_subtest "Removing info from filename leaves tags unchanged"
 add_message [subject]='"Message to lose maildir info"' [filename]='message-to-lose-maildir-info' [dir]=cur
 notmuch tag -unread subject:"Message to lose maildir info"
 mv "$MAIL_DIR/cur/message-to-lose-maildir-info:2,S" "$MAIL_DIR/cur/message-without-maildir-info"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 output+="
 "
 output+=$(notmuch search subject:"Message to lose maildir info" | notmuch_search_sanitize)
@@ -151,7 +151,7 @@ mv $MAIL_DIR/cur/adding-s-flag:2,S $MAIL_DIR/cur/adding-s-flag:2,
 mv $MAIL_DIR/cur/adding-with-s-flag:2,S $MAIL_DIR/cur/adding-with-s-flag:2,RS
 mv $MAIL_DIR/cur/message-to-move-to-cur:2,S $MAIL_DIR/cur/message-to-move-to-cur:2,DS
 notmuch dump --output=dump.txt
-NOTMUCH_NEW >/dev/null
+NOTMUCH_NEW_SANITIZE >/dev/null
 notmuch restore --input=dump.txt
 output=$(ls $MAIL_DIR/cur)
 test_expect_equal "$output" "$expected"
@@ -159,14 +159,14 @@ test_expect_equal "$output" "$expected"
 test_begin_subtest 'Adding flags to duplicate message tags the mail'
 add_message [subject]='"Duplicated message"' [dir]=cur [filename]='duplicated-message:2,'
 cp "$MAIL_DIR/cur/duplicated-message:2," "$MAIL_DIR/cur/duplicated-message-copy:2,RS"
-NOTMUCH_NEW > output
+NOTMUCH_NEW_SANITIZE > output
 notmuch search subject:"Duplicated message" | notmuch_search_sanitize >> output
 test_expect_equal "$(< output)" "No new mail.
 thread:XXX   2001-01-05 [1/1(2)] Notmuch Test Suite; Duplicated message (inbox replied)"
 
 test_begin_subtest "Adding duplicate message without flags does not remove tags"
 cp "$MAIL_DIR/cur/duplicated-message-copy:2,RS" "$MAIL_DIR/cur/duplicated-message-another-copy:2,"
-NOTMUCH_NEW > output
+NOTMUCH_NEW_SANITIZE > output
 notmuch search subject:"Duplicated message" | notmuch_search_sanitize >> output
 test_expect_equal "$(< output)" "No new mail.
 thread:XXX   2001-01-05 [1/1(3)] Notmuch Test Suite; Duplicated message (inbox replied)"
diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh
index a7497489..84715cf6 100755
--- a/test/T357-index-decryption.sh
+++ b/test/T357-index-decryption.sh
@@ -62,7 +62,7 @@ test_begin_subtest "message should go away after deletion"
 fname=$(notmuch search --output=files wumpus)
 contents="$(notmuch show --format=raw wumpus)"
 rm -f "$fname"
-notmuch new
+NOTMUCH_NEW
 output=$(notmuch search wumpus)
 expected=''
 test_expect_equal \
@@ -106,7 +106,7 @@ test_expect_equal \
 test_begin_subtest "delete all copies of the message"
 mid="$(notmuch search --output=messages wumpus)"
 rm -f $(notmuch search --output=files wumpus)
-notmuch new
+NOTMUCH_NEW
 output=$(notmuch search "id:$mid")
 expected=''
 test_expect_equal \
diff --git a/test/T370-search-folder-coherence.sh b/test/T370-search-folder-coherence.sh
index cf202bb3..40878a00 100755
--- a/test/T370-search-folder-coherence.sh
+++ b/test/T370-search-folder-coherence.sh
@@ -3,7 +3,7 @@ test_description='folder tags removed and added through file renames remain cons
 . $(dirname "$0")/test-lib.sh || exit 1
 
 test_begin_subtest "No new messages"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail."
 
 
@@ -11,14 +11,14 @@ test_begin_subtest "Single new message"
 generate_message
 file_x=$gen_msg_filename
 id_x=$gen_msg_id
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Add second folder for same message"
 dir=$(dirname $file_x)
 mkdir $dir/spam
 cp $file_x $dir/spam
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail."
 
 
@@ -36,7 +36,7 @@ test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1(2)] Notmu
 
 test_begin_subtest "Remove folder:spam copy of email"
 rm $dir/spam/$(basename $file_x)
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW_SANITIZE)
 test_expect_equal "$output" "No new mail. Detected 1 file rename."
 
 test_begin_subtest "No mails match the folder:spam search"
diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh
index 0f9e6d2e..3aeb1d1e 100755
--- a/test/T380-atomicity.sh
+++ b/test/T380-atomicity.sh
@@ -30,7 +30,7 @@ if test_require_external_prereq gdb; then
     generate_message [subject]='"Remove directory"' [filename]='remove-directory:2,' [dir]=.remove-dir
     generate_message [subject]='"Remove directory duplicate"' [filename]='remove-directory-duplicate:2,' [dir]=.remove-dir
     cp $MAIL_DIR/.remove-dir/remove-directory-duplicate:2, $MAIL_DIR/cur/
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
 
     # Make all maildir changes, but *don't* update the database
     generate_message [subject]='Added' [filename]='added:2,' [dir]=cur
diff --git a/test/T385-transactions.sh b/test/T385-transactions.sh
index d8bb502d..38b6fe46 100755
--- a/test/T385-transactions.sh
+++ b/test/T385-transactions.sh
@@ -19,7 +19,7 @@ do
 done
 
 test_begin_subtest "initial new"
-NOTMUCH_NEW > OUTPUT
+NOTMUCH_NEW_SANITIZE > OUTPUT
 cat <<EOF > EXPECTED
 Added 1024 new messages to the database.
 EOF
diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh
index e828efed..5c5b9881 100755
--- a/test/T395-ruby.sh
+++ b/test/T395-ruby.sh
@@ -68,7 +68,7 @@ EOF
 notmuch config set search.exclude_tags deleted
 generate_message '[subject]="Good"'
 generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>"
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 notmuch tag +deleted id:$gen_msg_id
 
 test_begin_subtest "omit excluded all"
diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index 35bf70c0..5b580726 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -107,14 +107,14 @@ for config in traditional profile explicit relative XDG split; do
     rm -rf ${HOOK_DIR}
     generate_message
     create_echo_hook "pre-new" expected output $HOOK_DIR
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
     test_expect_equal_file expected output
 
     test_begin_subtest "post-new is run [${config}]"
     rm -rf ${HOOK_DIR}
     generate_message
     create_echo_hook "post-new" expected output $HOOK_DIR
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
     test_expect_equal_file expected output
 
     test_begin_subtest "post-insert hook is run [${config}]"
@@ -129,14 +129,14 @@ for config in traditional profile explicit relative XDG split; do
     generate_message
     create_echo_hook "pre-new" pre-new.expected pre-new.output $HOOK_DIR
     create_echo_hook "post-new" post-new.expected post-new.output $HOOK_DIR
-    notmuch new > /dev/null
+    NOTMUCH_NEW > /dev/null
     test_expect_equal_file post-new.expected post-new.output
 
     test_begin_subtest "pre-new non-zero exit status (hook status) [${config}]"
     rm -rf ${HOOK_DIR}
     generate_message
     create_failing_hook "pre-new" $HOOK_DIR
-    output=`notmuch new 2>&1`
+    output=`NOTMUCH_NEW 2>&1`
     test_expect_equal "$output" "Error: pre-new hook failed with status 13"
 
     # depends on the previous subtest leaving broken hook behind
@@ -146,14 +146,14 @@ for config in traditional profile explicit relative XDG split; do
     # depends on the previous subtests leaving 1 new message behind
     test_begin_subtest "pre-new non-zero exit status aborts new [${config}]"
     rm -rf ${HOOK_DIR}
-    output=$(NOTMUCH_NEW)
+    output=$(NOTMUCH_NEW_SANITIZE)
     test_expect_equal "$output" "Added 1 new message to the database."
 
     test_begin_subtest "post-new non-zero exit status (hook status) [${config}]"
     rm -rf ${HOOK_DIR}
     generate_message
     create_failing_hook "post-new" $HOOK_DIR
-    NOTMUCH_NEW 2>output.stderr >output
+    NOTMUCH_NEW_SANITIZE 2>output.stderr >output
     cat output.stderr >> output
     echo "Added 1 new message to the database." > expected
     echo "Error: post-new hook failed with status 13" >> expected
@@ -176,7 +176,7 @@ for config in traditional profile explicit relative XDG split; do
     #!/bin/sh
     echo foo
 EOF
-    output=`notmuch new 2>&1`
+    output=`NOTMUCH_NEW 2>&1`
     test_expect_code 1 "notmuch new"
 
     test_begin_subtest "hook execution failure [${config}]"
@@ -191,13 +191,13 @@ EOF
     test_begin_subtest "post-new with write access [${config}]"
     rm -rf ${HOOK_DIR}
     create_write_hook "post-new" write.expected write.output $HOOK_DIR
-    NOTMUCH_NEW
+    NOTMUCH_NEW_SANITIZE
     test_expect_equal_file write.expected write.output
 
     test_begin_subtest "pre-new with write access [${config}]"
     rm -rf ${HOOK_DIR}
     create_write_hook "pre-new" write.expected write.output $HOOK_DIR
-    NOTMUCH_NEW
+    NOTMUCH_NEW_SANITIZE
     test_expect_equal_file write.expected write.output
 
     test_begin_subtest "add message in pre-new [${config}]"
@@ -206,7 +206,7 @@ EOF
     id1=$gen_msg_id
     create_change_hook "pre-new" $gen_msg_filename $HOOK_DIR
     generate_message '[subject]="add msg in new"'
-    NOTMUCH_NEW
+    NOTMUCH_NEW_SANITIZE
     notmuch search id:$id1 or id:$gen_msg_id | notmuch_search_sanitize > OUTPUT
     cat <<EOF | sed s'/^[ \t]*//' > EXPECTED
     thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; add msg in pre-new (inbox unread)
diff --git a/test/T455-emacs-charsets.sh b/test/T455-emacs-charsets.sh
index db03bb67..6c40d189 100755
--- a/test/T455-emacs-charsets.sh
+++ b/test/T455-emacs-charsets.sh
@@ -40,7 +40,7 @@ generate_message \
     '[content-transfer-encoding]=quoted-printable' \
     '[body]="Yen: =A2=44"'
 
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 
 # Test rendering
 
diff --git a/test/T465-emacs-unthreaded.sh b/test/T465-emacs-unthreaded.sh
index a3ff85fd..78094ba0 100755
--- a/test/T465-emacs-unthreaded.sh
+++ b/test/T465-emacs-unthreaded.sh
@@ -18,7 +18,7 @@ for num in $(seq 2 64); do
 done
 printf "End of search results.\n" >> EXPECTED.unthreaded
 
-notmuch new > new.output 2>&1
+NOTMUCH_NEW > new.output 2>&1
 
 test_begin_subtest "large thread"
 test_emacs '(let ((max-lisp-eval-depth 10))
diff --git a/test/T470-missing-headers.sh b/test/T470-missing-headers.sh
index 32b070ec..725b7f0a 100755
--- a/test/T470-missing-headers.sh
+++ b/test/T470-missing-headers.sh
@@ -20,7 +20,7 @@ From: Notmuch Test Suite <test_suite@notmuchmail.org>
 Body
 EOF
 
-NOTMUCH_NEW >/dev/null
+NOTMUCH_NEW_SANITIZE >/dev/null
 
 test_begin_subtest "Search: text"
 output=$(notmuch search '*' | notmuch_search_sanitize)
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index 5f0de2ed..71d5bd20 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -23,7 +23,7 @@ for key in 'multiple paths per message' \
     backup_database
     test_begin_subtest "upgrade is triggered by missing '$key'"
     delete_feature "$key"
-    output=$(notmuch new | grep Welcome)
+    output=$(NOTMUCH_NEW | grep Welcome)
     test_expect_equal \
 	"$output" \
 	"Welcome to a new version of notmuch! Your database will now be upgraded."
@@ -34,7 +34,7 @@ for key in 'multiple paths per message' \
     test_begin_subtest "backup can be restored ['$key']"
     notmuch dump > BEFORE
     delete_feature "$key"
-    notmuch new
+    NOTMUCH_NEW
     notmuch tag -inbox '*'
     dump_file=$(echo ${BACKUP_PATH}/dump*)
     notmuch restore --input=$dump_file
@@ -49,7 +49,7 @@ for key in 'from/subject/message-ID in database' \
     backup_database
     test_begin_subtest "upgrade not triggered by missing '$key'"
     delete_feature "$key"
-    output=$(notmuch new | grep Welcome)
+    output=$(NOTMUCH_NEW | grep Welcome)
     test_expect_equal "$output" ""
     restore_database
 done
@@ -57,7 +57,7 @@ done
 test_begin_subtest "upgrade with configured backup dir"
 notmuch config set database.backup_dir ${HOME}/backups
 delete_feature 'modification tracking'
-notmuch new | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
+NOTMUCH_NEW | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
 cat <<EOF > EXPECTED
 Backing up tags to CWD/home/backups/dump-XXX.gz...
 EOF
@@ -66,7 +66,7 @@ test_expect_equal_file EXPECTED OUTPUT
 test_begin_subtest "upgrade with relative configured backup dir"
 notmuch config set database.backup_dir ${HOME}/backups
 delete_feature 'modification tracking'
-notmuch new | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
+NOTMUCH_NEW | grep Backing | notmuch_dir_sanitize | sed 's/dump-[0-9T]*/dump-XXX/' > OUTPUT
 cat <<EOF > EXPECTED
 Backing up tags to CWD/home/backups/dump-XXX.gz...
 EOF
diff --git a/test/T550-db-features.sh b/test/T550-db-features.sh
index 9d5a9e70..53aae52e 100755
--- a/test/T550-db-features.sh
+++ b/test/T550-db-features.sh
@@ -14,7 +14,7 @@ Error: Notmuch database at FILENAME
 
 test_begin_subtest "unknown 'rw' feature aborts read/write open"
 ${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\trw'
-output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+output=$(NOTMUCH_NEW 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
 rm -rf ${MAIL_DIR}/.notmuch
 test_expect_equal "$output" "\
 Error: Notmuch database at FILENAME
@@ -32,7 +32,7 @@ Error: Notmuch database at FILENAME
 
 test_begin_subtest "unknown 'w' feature aborts read/write open"
 ${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\tw'
-output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+output=$(NOTMUCH_NEW 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
 rm -rf ${MAIL_DIR}/.notmuch
 test_expect_equal "$output" "\
 Error: Notmuch database at FILENAME
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index a2901ff6..0aefac0c 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -6,7 +6,7 @@ test_description="error reporting for library"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 test_begin_subtest "Open null pointer"
 test_C <<'EOF'
diff --git a/test/T562-lib-database.sh b/test/T562-lib-database.sh
index fedfc9ed..6838f12e 100755
--- a/test/T562-lib-database.sh
+++ b/test/T562-lib-database.sh
@@ -6,7 +6,7 @@ test_description="notmuch_database_* API"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 cat <<EOF > c_head
 #include <notmuch-test.h>
diff --git a/test/T563-lib-directory.sh b/test/T563-lib-directory.sh
index 4711fcdf..3b633a7b 100755
--- a/test/T563-lib-directory.sh
+++ b/test/T563-lib-directory.sh
@@ -6,7 +6,7 @@ test_description="notmuch_directory_* API"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 cat <<EOF > c_head
 #include <notmuch-test.h>
diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh
index 53a63bf6..e10edd70 100755
--- a/test/T564-lib-query.sh
+++ b/test/T564-lib-query.sh
@@ -6,7 +6,7 @@ test_description="notmuch_query_* API"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 cat <<EOF > c_head
 #include <notmuch-test.h>
diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 511d56ca..521ffba0 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -6,7 +6,7 @@ test_description="API tests for notmuch_message_*"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 cat <<'EOF' > c_tail
    if (stat) {
diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index b4c24ca2..5eec191b 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -6,7 +6,7 @@ test_description="API tests for notmuch_thread_*"
 add_email_corpus
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 test_begin_subtest "finding thread"
 THREAD=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
diff --git a/test/T592-thread-breakage.sh b/test/T592-thread-breakage.sh
index 92a70e3e..a17ef50e 100755
--- a/test/T592-thread-breakage.sh
+++ b/test/T592-thread-breakage.sh
@@ -70,41 +70,41 @@ test_ghost_count () {
     test_expect_equal "$ghosts" "$1"
 }
 
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 
 test_thread_count 0 'There should be no threads initially'
 test_ghost_count 0 'There should be no ghosts initially'
 
 message_a
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 1 'One message in: one thread'
 test_content_count apple 1
 test_content_count banana 0
 test_ghost_count 0
 
 message_b
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 1 'Second message in the same thread: one thread'
 test_content_count apple 1
 test_content_count banana 1
 test_ghost_count 0
 
 rm -f ${MAIL_DIR}/cur/a
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 1 'First message removed: still only one thread'
 test_content_count apple 0
 test_content_count banana 1
 test_ghost_count 1 'should be one ghost after first message removed'
 
 message_a
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 1 'First message reappears: should return to the same thread'
 test_content_count apple 1
 test_content_count banana 1
 test_ghost_count 0
 
 rm -f ${MAIL_DIR}/cur/b
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 1 'Removing second message: still only one thread'
 test_content_count apple 1
 test_content_count banana 0
@@ -115,7 +115,7 @@ ghosts=$($NOTMUCH_BUILDDIR/test/ghost-report ${MAIL_DIR}/.notmuch/xapian)
 test_expect_equal "$ghosts" "0"
 
 rm -f ${MAIL_DIR}/cur/a
-notmuch new >/dev/null
+NOTMUCH_NEW >/dev/null
 test_thread_count 0 'All messages gone: no threads'
 test_content_count apple 0
 test_content_count banana 0
diff --git a/test/T720-lib-lifetime.sh b/test/T720-lib-lifetime.sh
index e5afeaa2..2b306cb9 100755
--- a/test/T720-lib-lifetime.sh
+++ b/test/T720-lib-lifetime.sh
@@ -11,7 +11,7 @@ test_description="Lifetime constraints for library"
 add_email_corpus threading
 
 test_begin_subtest "building database"
-test_expect_success "NOTMUCH_NEW"
+test_expect_success "NOTMUCH_NEW_SANITIZE"
 
 test_begin_subtest "Message outlives parent Messages from replies"
 
diff --git a/test/T750-gzip.sh b/test/T750-gzip.sh
index 5648896f..cbec22ca 100755
--- a/test/T750-gzip.sh
+++ b/test/T750-gzip.sh
@@ -7,35 +7,35 @@ test_description='support for gzipped messages'
 test_begin_subtest "Single new gzipped message"
 generate_message
 gzip $gen_msg_filename
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Single new gzipped message (full-scan)"
 generate_message
 gzip $gen_msg_filename
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" "Added 1 new message to the database."
 
 test_begin_subtest "Multiple new messages, one gzipped"
 generate_message
 gzip $gen_msg_filename
 generate_message
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "Added 2 new messages to the database."
 
 test_begin_subtest "Multiple new messages, one gzipped (full-scan)"
 generate_message
 gzip $gen_msg_filename
 generate_message
-output=$(NOTMUCH_NEW --debug --full-scan 2>&1)
+output=$(NOTMUCH_NEW_SANITIZE --debug --full-scan 2>&1)
 test_expect_equal "$output" "Added 2 new messages to the database."
 
 test_begin_subtest "Renamed (gzipped) message"
 generate_message
 echo $gen_message_filename
-notmuch new > /dev/null
+NOTMUCH_NEW > /dev/null
 gzip $gen_msg_filename
-output=$(NOTMUCH_NEW --debug)
+output=$(NOTMUCH_NEW_SANITIZE --debug)
 test_expect_equal "$output" "(D) add_files, pass 2: queuing passed file ${gen_msg_filename} for deletion from database
 No new mail. Detected 1 file rename."
 
diff --git a/test/test-lib-emacs.sh b/test/test-lib-emacs.sh
index ad4c4aeb..d5827751 100644
--- a/test/test-lib-emacs.sh
+++ b/test/test-lib-emacs.sh
@@ -61,7 +61,7 @@ emacs_deliver_message () {
     # before exiting and resuming control here; therefore making sure
     # that server exits by sending (KILL) signal to it is safe.
     kill -9 $smtp_dummy_pid
-    notmuch new >/dev/null
+    NOTMUCH_NEW >/dev/null
 }
 
 # Pretend to deliver a message with emacs. Really save it to a file
@@ -102,7 +102,7 @@ emacs_fcc_message () {
 	   (let ((mml-secure-smime-sign-with-sender t)
 		 (mml-secure-openpgp-sign-with-sender t))
 	     (notmuch-mua-send-and-exit)))" || return 1
-    notmuch new $nmn_args >/dev/null
+    NOTMUCH_NEW $nmn_args >/dev/null
 }
 
 test_emacs_expect_t () {
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 9f10aa89..eadfa0f7 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -299,7 +299,7 @@ add_email_corpus () {
 
     rm -rf ${MAIL_DIR}
     cp -a $NOTMUCH_SRCDIR/test/corpora/$corpus ${MAIL_DIR}
-    notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus"
+    notmuch new $NOTMUCH_NEW_OPTIONS >/dev/null || die "'notmuch new' failed while adding email corpus"
 }
 
 test_begin_subtest () {
@@ -468,6 +468,10 @@ test_json_nodes () {
 }
 
 NOTMUCH_NEW () {
+    notmuch new $NOTMUCH_NEW_OPTIONS "${@}"
+}
+
+NOTMUCH_NEW_SANITIZE () {
     notmuch new $NOTMUCH_NEW_OPTIONS "${@}" | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
 }
 
-- 
2.41.0.rc1.178.gd8fba8690d