2 test_description='hooks'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 create_echo_script () {
6 local TOKEN="${RANDOM}"
8 cat <<EOF >"${BIN_DIR}/${1}"
10 echo "${TOKEN}" > ${3}
12 chmod +x "${BIN_DIR}/${1}"
13 echo "${TOKEN}" > ${2}
16 create_printenv_script () {
18 cat <<EOF >"${BIN_DIR}/${1}"
20 printenv "${2}" > "${3}"
22 chmod +x "${BIN_DIR}/${1}"
25 # add a message to generate mail dir and database
31 test_begin_subtest "'notmuch foo' runs notmuch-foo"
33 create_echo_script "notmuch-foo" EXPECTED OUTPUT $HOOK_DIR
35 test_expect_equal_file_nonempty EXPECTED OUTPUT
37 create_printenv_script "notmuch-printenv" NOTMUCH_CONFIG OUTPUT
39 test_begin_subtest "NOTMUCH_CONFIG is set"
44 test_expect_equal_file_nonempty EXPECTED OUTPUT
46 test_begin_subtest "NOTMUCH_CONFIG is set by --config"
47 cp "${NOTMUCH_CONFIG}" "${NOTMUCH_CONFIG}.alternate"
49 ${NOTMUCH_CONFIG}.alternate
51 notmuch --config "${NOTMUCH_CONFIG}.alternate" printenv
52 test_expect_equal_file_nonempty EXPECTED OUTPUT