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.
31 #### Assume that script(1) uses SHELL environment variable.
35 #### Run a command but don't wait for user input. script(1) seems to do
36 #### what we want by not waiting when run in the background. But check
37 #### that it makes the command look like it's connected to a terminal below.
39 #### Create a command to use as a shell for script.
46 if [ ${use_dash_S} -eq 1 ]; then
47 script -S "${cmd}" "${actual}" >/dev
/null
&
49 SHELL
="${cmd}" script "${actual}" >/dev
/null
&
55 #### Ensure that script(1) makes the program look like it's connected to a
56 #### terminal. The welcome message code in sbr/utils.c needs that.
57 run_without_input
'if test -t 0 && test -t 1 && test -t 2; then echo tty; fi'
58 grep tty
"${actual}" >/dev
/null
|| test_skip
"(script(1) doesn't simulate tty)"
61 # Removing Version will trigger the welcome message. (setup_test
62 # inserted it so that other tests wouldn't show it.)
63 grep -v Version
"${context}" > "${context}.NEW"
64 mv -f "${context}.NEW" "${context}"
67 start_test
'mhparam skips the welcome message'
68 run_without_input mhparam path
69 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
70 # Make sure that version wasn't added to context.
71 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
75 start_test
'Welcome: disable in profile skips the welcome message'
76 cp "${MH}" "${MH}-welcome"
77 printf 'Welcome: disable\n' >> "${MH}-welcome"
78 # Run the function in subshell instead of augmenting the environment
79 # for a single command, so that the environment does not retain the
80 # MH setting. That can happen when run under distcheck, depending
81 # on the user's shell.
82 (MH
="${MH}-welcome"; run_without_input pick last
)
84 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
85 # Make sure that version wasn't added to context.
86 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
90 start_test
'with welcome message'
91 run_without_input pick last
92 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
93 # Make sure that version was added to context.
94 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
98 start_test
'without welcome message'
99 # After running the previous test, this one should not have
100 # the welcome message.
101 run_without_input pick last
102 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
103 # Make sure that version is still in context.
104 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
108 start_test
'with MHCONTEXT, welcome only if older'
109 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
110 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
111 run_without_input pick last
112 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
113 # And make sure that version did get updated in context.
114 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
118 start_test
"with MHCONTEXT doesn't welcome if newer"
119 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
120 run_without_input pick last
121 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
122 # And make sure that version didn't get updated in context.
123 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
127 start_test
'with MHCONTEXT but no version, no welcome and update'
128 printf '' >"${MHCONTEXT}"
129 run_without_input pick last
130 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
131 # And make sure that version did get updated in context.
132 grep "^${version}$" "${MHCONTEXT}" >/dev
/null