[PATCH 6/8] test: add known broken tests for finding database via MAILDIR

Subject: [PATCH 6/8] test: add known broken tests for finding database via MAILDIR

Date: Mon, 2 Aug 2021 12:09:20 -0300

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


This highlights a bug reported by several users, including
Mohsin Kaleem [1].

The use of test_begin_subtest is because these tests pass even though
the database cannot be located.

[1]: id:87bl9lx864.fsf@kisara.moe
---
 test/T055-path-config.sh | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh
index 035276c2..40601acd 100755
--- a/test/T055-path-config.sh
+++ b/test/T055-path-config.sh
@@ -16,6 +16,7 @@ restore_config () {
     unset DATABASE_PATH
     unset NOTMUCH_PROFILE
     unset XAPIAN_PATH
+    unset MAILDIR
     rm -f "$HOME/mail"
     cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
 }
@@ -55,6 +56,18 @@ home_mail_config () {
     unset DATABASE_PATH
 }
 
+maildir_env_config () {
+    local dir
+    backup_config
+    dir="${HOME}/env_points_here"
+    ln -s $MAIL_DIR $dir
+    export MAILDIR=$dir
+    notmuch config set database.path
+    notmuch config set database.mail_root
+    XAPIAN_PATH="${MAIL_DIR}/.notmuch/xapian"
+    unset DATABASE_PATH
+}
+
 xdg_config () {
     local dir
     local profile=${1:-default}
@@ -84,9 +97,12 @@ config_subtest () {
     local config=$2
 
     test_begin_subtest "$title ($config)"
+    if [[ "$config" == "maildir_env" ]]; then
+	test_subtest_known_broken
+    fi
 }
 
-for config in traditional split XDG XDG+profile symlink home_mail; do
+for config in traditional split XDG XDG+profile symlink home_mail maildir_env; do
     #start each set of tests with an known set of messages
     add_email_corpus
 
@@ -224,7 +240,7 @@ EOF
 	"$output" \
 	"Welcome to a new version of notmuch! Your database will now be upgraded."
 
-    config_subtest "notmuch +config -database suggests notmuch new" "$config"
+    test_begin_subtest "notmuch +config -database suggests notmuch new" "$config"
     mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
     notmuch > OUTPUT
 cat <<EOF > EXPECTED
@@ -240,7 +256,7 @@ EOF
 
    test_expect_equal_file EXPECTED OUTPUT
 
-   config_subtest "Set config value" "$config"
+   test_begin_subtest "Set config value" "$config"
    name=${RANDOM}
    value=${RANDOM}
    notmuch config set test${test_count}.${name} ${value}
@@ -259,11 +275,13 @@ EOF
    test_expect_equal "${output}+${output2}" "${value}+"
 
    config_subtest "Config list" "$config"
-   notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/"  \
-						    -e "s/^database.hook_dir=.*$/database.hook_dir/" \
-						    -e "s/^database.path=.*$/database.path/"  \
-						    -e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
-						    > OUTPUT
+   notmuch config list | notmuch_dir_sanitize | \
+       sed -e "s/^database.backup_dir=.*$/database.backup_dir/"  \
+	   -e "s/^database.hook_dir=.*$/database.hook_dir/" \
+	   -e "s/^database.path=.*$/database.path/"  \
+	   -e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
+	   -e "s,^database.mail_root=CWD/home/env_points_here,database.mail_root=MAIL_DIR," \
+	   > OUTPUT
    cat <<EOF > EXPECTED
 built_with.compact=true
 built_with.field_processor=true
-- 
2.30.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: