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"
22 actual
="${MH_TEST_DIR}/test-version-check$$.actual"
23 context
="${MH_TEST_DIR}"/Mail
/context
24 version
="Version: nmh-${MH_VERSION}"
25 cmd
="${MH_TEST_DIR}/Mail/cmd"
27 if script -S /bin
/sh
'echo OK' /dev
/null
2>&1 | egrep 'OK' >/dev
/null
; then
28 #### script(1) uses -S to set the shell that it runs.
37 (SHELL
="${cmd}"; export SHELL
; script "${actual}" >/dev
/null
&
39 if grep OK
"${actual}" >/dev
/null
; then
40 #### script(1) supports SHELL environment variable.
43 test_skip
"can't find mechanism to set SHELL for script(1)"
47 #### Run a command but don't wait for user input. script(1) seems to do
48 #### what we want by not waiting when run in the background. But check
49 #### that it makes the command look like it's connected to a terminal below.
51 #### Create a command to use as a shell for script.
58 if [ ${use_dash_S} -eq 1 ]; then
59 script -S "${cmd}" "${actual}" >/dev
/null
&
61 SHELL
="${cmd}" script "${actual}" >/dev
/null
&
67 #### Ensure that script(1) makes the program look like it's connected to a
68 #### terminal. The welcome message code in sbr/utils.c needs that.
69 run_without_input
'if test -t 0 -a -t 1 -a -t 2; then echo tty; fi'
70 grep tty
"${actual}" >/dev
/null
|| test_skip
"script(1) doesn't simulate tty"
73 # Removing Version will trigger the welcome message. (setup_test
74 # inserted it so that other tests wouldn't show it.)
75 grep -v Version
"${context}" > "${context}.NEW"
76 mv -f "${context}.NEW" "${context}"
79 start_test
'mhparam skips the welcome message'
80 run_without_input mhparam path
81 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
82 # Make sure that version wasn't added to context.
83 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
87 start_test
'Welcome: disable in profile skips the welcome message'
88 cp "${MH}" "${MH}-welcome"
89 printf 'Welcome: disable\n' >> "${MH}-welcome"
90 # Run the function in subshell instead of augmenting the environment
91 # for a single command, so that the environment does not retain the
92 # MH setting. That can happen when run under distcheck, depending
93 # on the user's shell.
94 (MH
="${MH}-welcome"; run_without_input pick last
)
96 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
97 # Make sure that version wasn't added to context.
98 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
102 start_test
'with welcome message'
103 run_without_input pick last
104 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
105 # Make sure that version was added to context.
106 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
110 start_test
'without welcome message'
111 # After running the previous test, this one should not have
112 # the welcome message.
113 run_without_input pick last
114 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
115 # Make sure that version is still in context.
116 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
120 start_test
'with MHCONTEXT, welcome only if older'
121 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
122 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
123 run_without_input pick last
124 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
125 # And make sure that version did get updated in context.
126 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
130 start_test
"with MHCONTEXT doesn't welcome if newer"
131 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
132 run_without_input pick last
133 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
134 # And make sure that version didn't get updated in context.
135 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
139 start_test
'with MHCONTEXT but no version, no welcome and update'
140 printf '' >"${MHCONTEXT}"
141 run_without_input pick last
142 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
143 # And make sure that version did get updated in context.
144 grep "^${version}$" "${MHCONTEXT}" >/dev
/null