X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/49b128f0607611e485a06c21dcb48e4144b63d5e..1f13f2cc1b7c1ca62969bc658712dac22fb21b6f:/test/install-mh/test-version-check?ds=sidebyside diff --git a/test/install-mh/test-version-check b/test/install-mh/test-version-check index b8a91b68..def3cda4 100755 --- a/test/install-mh/test-version-check +++ b/test/install-mh/test-version-check @@ -18,28 +18,84 @@ fi setup_test require_prog script +#### Use minimal arguments to script(1), i.e., just the file in +#### which to save the output. We do pipe input to script, which is +#### discouraged by the NOTES and BUGS sections of its man page. +#### But that seems to work. actual="$MH_TEST_DIR/test-version-check$$.actual" context="${MH_TEST_DIR}"/Mail/context +version="Version: nmh-${MH_VERSION}" - -start_test 'with welcome message' -# Removing Version will trigger the welcome message. +# Removing Version will trigger the welcome message. (setup_test +# inserted it so that other tests wouldn't show it.) grep -v Version "$context" > "$context.NEW" mv -f "$context.NEW" "$context" -script -c 'pick last' -q "$actual" >/dev/null + + +start_test 'mhparam skips the welcome message' +printf 'mhparam path\nexit\n' | script "$actual" >/dev/null +grep 'Welcome to nmh version ' "$actual" >/dev/null && false +# Make sure that version wasn't added to context. +grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false +rm "$actual" + + +start_test 'Welcome: disable in profile skips the welcome message' +cp "${MH}" "${MH}-welcome" +printf 'Welcome: disable\n' >> "${MH}-welcome" +(printf 'pick last\nexit\n' | MH="${MH}-welcome" script "$actual" >/dev/null) +grep 'Welcome to nmh version ' "$actual" >/dev/null && false +# Make sure that version wasn't added to context. +grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false +rm "$actual" + + +start_test 'with welcome message' +printf 'pick last\nexit\n' | script "$actual" >/dev/null grep 'Welcome to nmh version ' "$actual" >/dev/null +# Make sure that version was added to context. +grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null rm "$actual" -finish_test start_test 'without welcome message' # After running the previous test, this one should not have # the welcome message. -script -c 'pick last' -q "$actual" >/dev/null +printf 'pick last\nexit\n' | script "$actual" >/dev/null grep 'Welcome to nmh version ' "$actual" >/dev/null && false +# Make sure that version is still in context. +grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null +rm "$actual" + + +start_test 'with MHCONTEXT, welcome only if older' +MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT +printf 'Version: nmh-1.5\n' >"${MHCONTEXT}" +printf 'pick last\nexit\n' | script "$actual" >/dev/null +grep 'Welcome to nmh version ' "$actual" >/dev/null +# And make sure that version did get updated in context. +grep "^${version}$" "${MHCONTEXT}" >/dev/null +rm "$actual" + + +start_test "with MHCONTEXT doesn't welcome if newer" +printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}" +printf 'pick last\nexit\n' | script "$actual" >/dev/null +grep 'Welcome to nmh version ' "$actual" >/dev/null && false +# And make sure that version didn't get updated in context. +grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null rm "$actual" -finish_test +start_test 'with MHCONTEXT but no version, no welcome and update' +printf '' >"${MHCONTEXT}" +printf 'pick last\nexit\n' | script "$actual" >/dev/null +grep 'Welcome to nmh version ' "$actual" >/dev/null && false +# And make sure that version did get updated in context. +grep "^${version}$" "${MHCONTEXT}" >/dev/null +rm "$actual" + + +finish_test exit $failed