X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT055-path-config.sh;h=4897c8142ac73ea47023744cafcfd966985f1a98;hp=8ef76aed9273305f0b977eb8d4d4ee3bbdb58474;hb=HEAD;hpb=c84ccb70f3ed2b2228346499b5110311039a0ecf diff --git a/test/T055-path-config.sh b/test/T055-path-config.sh index 8ef76aed..1feb5624 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} @@ -79,7 +92,20 @@ xdg_config () { notmuch --config=${CONFIG_PATH} config set database.path } -for config in traditional split XDG XDG+profile symlink home_mail; do +mailroot_only_config () { + local dir + + backup_config + notmuch config set database.mail_root ${TMP_DIRECTORY}/mail + notmuch config set database.path + DATABASE_PATH="${HOME}/.local/share/notmuch/default" + rm -rf $DATABASE_PATH + mkdir -p $DATABASE_PATH + XAPIAN_PATH="${DATABASE_PATH}/xapian" + mv mail/.notmuch/xapian $DATABASE_PATH +} + +for config in traditional split XDG XDG+profile symlink home_mail maildir_env mailroot_only; do #start each set of tests with an known set of messages add_email_corpus @@ -106,6 +132,12 @@ for config in traditional split XDG XDG+profile symlink home_mail; do home_mail) home_mail_config ;; + maildir_env) + maildir_env_config + ;; + mailroot_only) + mailroot_only_config + ;; esac test_begin_subtest "count ($config)" @@ -141,13 +173,13 @@ EOF notmuch tag -inbox '*' notmuch restore < EXPECTED notmuch dump > OUTPUT - test_expect_equal_file EXPECTED OUTPUT + test_expect_equal_file_nonempty EXPECTED OUTPUT test_begin_subtest "reindex ($config)" notmuch search --output=messages '*' > EXPECTED notmuch reindex '*' notmuch search --output=messages '*' > OUTPUT - test_expect_equal_file EXPECTED OUTPUT + test_expect_equal_file_nonempty EXPECTED OUTPUT test_begin_subtest "use existing database ($config)" output=$(notmuch new) @@ -169,7 +201,7 @@ EOF test_begin_subtest "Show a raw message ($config)" add_message notmuch show --format=raw id:$gen_msg_id > OUTPUT - test_expect_equal_file $gen_msg_filename OUTPUT + test_expect_equal_file_nonempty $gen_msg_filename OUTPUT rm -f $gen_msg_filename test_begin_subtest "reply ($config)" @@ -190,6 +222,7 @@ On Tue, 05 Jan 2010 15:43:56 -0000, Sender wrote: > basic reply test EOF test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "insert+search ($config)" generate_message \ "[subject]=\"insert-subject\"" \ @@ -198,14 +231,13 @@ EOF mkdir -p "$MAIL_DIR"/{cur,new,tmp} notmuch insert < "$gen_msg_filename" cur_msg_filename=$(notmuch search --output=files "subject:insert-subject") - test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename" - + test_expect_equal_file_nonempty "$cur_msg_filename" "$gen_msg_filename" test_begin_subtest "compact+search ($config)" notmuch search --output=messages '*' | sort > EXPECTED notmuch compact notmuch search --output=messages '*' | sort > OUTPUT - test_expect_equal_file EXPECTED OUTPUT + test_expect_equal_file_nonempty EXPECTED OUTPUT test_begin_subtest "upgrade backup ($config)" features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths") @@ -250,19 +282,24 @@ EOF test_expect_equal "${output}+${output2}" "${value}+" test_begin_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_config_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 < EXPECTED -built_with.compact=true -built_with.field_processor=true -built_with.retry_lock=true +built_with.compact=something +built_with.field_processor=something +built_with.retry_lock=something +built_with.sexp_queries=something +database.autocommit=8000 database.backup_dir database.hook_dir database.mail_root=MAIL_DIR database.path +index.as_text= maildir.synchronize_flags=true new.ignore= new.tags=unread;inbox @@ -273,6 +310,27 @@ user.primary_email=test_suite@notmuchmail.org EOF test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "Config list from python ($config)" + test_python < OUTPUT +from notmuch2 import Database +db=Database(config=Database.CONFIG.SEARCH) +for key in list(db.config): + print(key) +EOF + cat < EXPECTED +database.autocommit +database.backup_dir +database.hook_dir +database.mail_root +database.path +maildir.synchronize_flags +new.tags +user.name +user.other_email +user.primary_email +EOF + test_expect_equal_file EXPECTED OUTPUT + case $config in XDG*) test_begin_subtest "Set shadowed config value in database ($config)" @@ -286,8 +344,50 @@ EOF output2=$(notmuch --config='' config get ${key}) notmuch config set ${key} test_expect_equal "${output}+${output2}" "${value}+" + ;& + split) + test_begin_subtest "'to' header does not crash (python-cffi) ($config)" + echo 'notmuch@notmuchmail.org' > EXPECTED + test_python < OUTPUT + notmuch search subject:Do-not-ignore | notmuch_search_sanitize >> OUTPUT + cat < EXPECTED +Added 1 new message to the database. +thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Do not ignore, very important (inbox unread) +EOF + test_expect_equal_file EXPECTED OUTPUT + ;& + mailroot_only) + test_begin_subtest "create database parent dir ($config)" + rm -r ${DATABASE_PATH} + notmuch new + test_expect_equal "$(xapian-metadata get ${XAPIAN_PATH} version)" 3 + ;; + home_mail|maildir_env) + test_begin_subtest "No errors from config list ($config)" + notmuch config list 2>OUTPUT 1>/dev/null + test_expect_equal_file /dev/null OUTPUT + ;; + *) + backup_database + test_begin_subtest ".notmuch without xapian/ handled gracefully ($config)" + rm -r $XAPIAN_PATH + test_expect_success "notmuch new" + restore_database ;; esac + restore_config rm -rf home/.local rm -rf home/.config