2 ######################################################
4 # Test display of new version welcome message. This
5 # doesn't really belong in install-mh.
7 ######################################################
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir
=`dirname $0`/..
/..
13 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
16 .
"${MH_OBJ_DIR}/test/common.sh"
19 require_runpty_to_simulate_tty
21 actual
="${MH_TEST_DIR}/test-version-check$$.actual"
22 context
="${MH_TEST_DIR}"/Mail
/context
23 version
="Version: nmh-${MH_VERSION}"
25 # Removing Version will trigger the welcome message. (setup_test
26 # inserted it so that other tests wouldn't show it.)
27 grep -v Version
"${context}" > "${context}.NEW"
28 mv -f "${context}.NEW" "${context}"
31 start_test
'mhparam skips the welcome message'
32 run_without_input
"${actual}" mhparam path
33 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
34 # Make sure that version wasn't added to context.
35 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
39 start_test
'Welcome: disable in profile skips the welcome message'
40 cp "${MH}" "${MH}-welcome"
41 printf 'Welcome: disable\n' >> "${MH}-welcome"
42 # Run the function in subshell instead of augmenting the environment
43 # for a single command, so that the environment does not retain the
44 # MH setting. That can happen when run under distcheck, depending
45 # on the user's shell.
46 (MH
="${MH}-welcome"; run_without_input
"${actual}" pick last
)
48 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
49 # Make sure that version wasn't added to context.
50 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
54 start_test
'with welcome message'
55 run_without_input
"${actual}" pick last
56 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
57 # Make sure that version was added to context.
58 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
62 start_test
'without welcome message'
63 # After running the previous test, this one should not have
64 # the welcome message.
65 run_without_input
"${actual}" pick last
66 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
67 # Make sure that version is still in context.
68 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
72 start_test
'with MHCONTEXT, welcome only if older'
73 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
74 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
75 run_without_input
"${actual}" pick last
76 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
77 # And make sure that version did get updated in context.
78 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
82 start_test
"with MHCONTEXT doesn't welcome if newer"
83 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
84 run_without_input
"${actual}" pick last
85 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
86 # And make sure that version didn't get updated in context.
87 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
91 start_test
'with MHCONTEXT but no version, no welcome and update'
92 printf '' >"${MHCONTEXT}"
93 run_without_input
"${actual}" pick last
94 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
95 # And make sure that version did get updated in context.
96 grep "^${version}$" "${MHCONTEXT}" >/dev
/null