diff options
| author | David Bremner <david@tethera.net> | 2022-05-31 08:50:58 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2022-06-13 07:27:06 -0300 |
| commit | eaa5199f5bf761d3b57f7ed22e125e716446a1cb (patch) | |
| tree | 20939fd2a08cd646e0c304e1b2efae85757f42d3 /test | |
| parent | 82957c963296bb9d2147ce5374b940463facd9ec (diff) | |
test: initial tests for external commands
The main goal is to test the setting of NOTMUCH_CONFIG, but also
include a basic sanity test for execing scripts.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/T405-external.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/T405-external.sh b/test/T405-external.sh new file mode 100755 index 00000000..b121fc72 --- /dev/null +++ b/test/T405-external.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +test_description='hooks' +. $(dirname "$0")/test-lib.sh || exit 1 + +create_echo_script () { + local TOKEN="${RANDOM}" + mkdir -p ${BIN_DIR} + cat <<EOF >"${BIN_DIR}/${1}" +#!/bin/sh +echo "${TOKEN}" > ${3} +EOF + chmod +x "${BIN_DIR}/${1}" + echo "${TOKEN}" > ${2} +} + +create_printenv_script () { + mkdir -p ${BIN_DIR} + cat <<EOF >"${BIN_DIR}/${1}" +#!/bin/sh +printenv "${2}" > "${3}" +EOF + chmod +x "${BIN_DIR}/${1}" +} + +# add a message to generate mail dir and database +add_message + +BIN_DIR=`pwd`/bin +PATH=$BIN_DIR:$PATH + +test_begin_subtest "'notmuch foo' runs notmuch-foo" +rm -rf ${BIN_DIR} +create_echo_script "notmuch-foo" EXPECTED OUTPUT $HOOK_DIR +notmuch foo +test_expect_equal_file_nonempty EXPECTED OUTPUT + +create_printenv_script "notmuch-printenv" NOTMUCH_CONFIG OUTPUT + +test_begin_subtest "NOTMUCH_CONFIG is set" +notmuch printenv +cat <<EOF > EXPECTED +${NOTMUCH_CONFIG} +EOF +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "NOTMUCH_CONFIG is set by --config" +test_subtest_known_broken +cp "${NOTMUCH_CONFIG}" "${NOTMUCH_CONFIG}.alternate" +cat <<EOF > EXPECTED +${NOTMUCH_CONFIG}.alternate +EOF +notmuch --config "${NOTMUCH_CONFIG}.alternate" printenv +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_done |
