Setting this according to --config was requested by Uwe
Kleine-König. There are some other ways that the configuration file
might be found in current notmuch, so check those as well.
As a bonus, fix a bug in the hook tests that left NOTMUCH_CONFIG set
even though a config file was provided via NOTMUCH_PROFILE.
[1]: id:
8baa58c3-7ab9-ec03-1bbd-
28aa5be838f2@kleine-koenig.org
+create_printenv_hook () {
+ mkdir -p ${HOOK_DIR}
+ cat <<EOF >"${HOOK_DIR}/${1}"
+#!/bin/sh
+printenv "${2}" > "${3}"
+EOF
+ chmod +x "${HOOK_DIR}/${1}"
+}
+
create_write_hook () {
local TOKEN="${RANDOM}"
mkdir -p ${HOOK_DIR}
create_write_hook () {
local TOKEN="${RANDOM}"
mkdir -p ${HOOK_DIR}
# create maildir structure for notmuch-insert
mkdir -p "$MAIL_DIR"/{cur,new,tmp}
# create maildir structure for notmuch-insert
mkdir -p "$MAIL_DIR"/{cur,new,tmp}
+ORIG_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
for config in traditional profile explicit relative XDG split; do
unset NOTMUCH_PROFILE
for config in traditional profile explicit relative XDG split; do
unset NOTMUCH_PROFILE
+ export NOTMUCH_CONFIG=${ORIG_NOTMUCH_CONFIG}
+ EXPECTED_CONFIG=${NOTMUCH_CONFIG}
notmuch config set database.hook_dir
notmuch config set database.path ${MAIL_DIR}
case $config in
notmuch config set database.hook_dir
notmuch config set database.path ${MAIL_DIR}
case $config in
dir=${HOME}/.config/notmuch/other
mkdir -p ${dir}
HOOK_DIR=${dir}/hooks
dir=${HOME}/.config/notmuch/other
mkdir -p ${dir}
HOOK_DIR=${dir}/hooks
- cp ${NOTMUCH_CONFIG} ${dir}/config
+ EXPECTED_CONFIG=${dir}/config
+ cp ${NOTMUCH_CONFIG} ${EXPECTED_CONFIG}
export NOTMUCH_PROFILE=other
export NOTMUCH_PROFILE=other
;;
explicit)
HOOK_DIR=${HOME}/.notmuch-hooks
;;
explicit)
HOOK_DIR=${HOME}/.notmuch-hooks
EOF
test_expect_equal_file EXPECTED OUTPUT
EOF
test_expect_equal_file EXPECTED OUTPUT
+ test_begin_subtest "NOTMUCH_CONFIG is set"
+ if [ "${config}" = "profile" ]; then
+ test_subtest_known_broken
+ fi
+ create_printenv_hook "pre-new" NOTMUCH_CONFIG OUTPUT
+ NOTMUCH_NEW
+ cat <<EOF > EXPECTED
+${EXPECTED_CONFIG}
+EOF
+ test_expect_equal_file_nonempty EXPECTED OUTPUT
+
+ test_begin_subtest "NOTMUCH_CONFIG is set by --config"
+ test_subtest_known_broken
+ create_printenv_hook "pre-new" NOTMUCH_CONFIG OUTPUT
+ cp "${EXPECTED_CONFIG}" "${EXPECTED_CONFIG}.alternate"
+ notmuch --config "${EXPECTED_CONFIG}.alternate" new
+ cat <<EOF > EXPECTED
+${EXPECTED_CONFIG}.alternate
+EOF
+ test_expect_equal_file_nonempty EXPECTED OUTPUT
+
rm -rf ${HOOK_DIR}
done
test_done
rm -rf ${HOOK_DIR}
done
test_done