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"
20 actual
="${MH_TEST_DIR}/test-version-check$$.actual"
21 context
="${MH_TEST_DIR}"/Mail
/context
22 version
="Version: nmh-${MH_VERSION}"
23 cmd
="${MH_TEST_DIR}/Mail/cmd"
24 runpty
="${MH_OBJ_DIR}/test/runpty"
26 #### Run a command but don't wait for user input. We switched from script(1)
27 #### to our own utility, runpty. Check that it makes the command look like
28 #### it's connected to a terminal below.
30 #### Create a command to use as a shell for script.
37 "$runpty" "${actual}" "${cmd}"
40 #### Ensure that runpty makes the program look like it's connected to a
41 #### terminal. The welcome message code in sbr/utils.c needs that.
42 run_without_input
'if test -t 0 -a -t 1 -a -t 2; then echo tty; fi'
43 grep tty
"${actual}" >/dev
/null
|| test_skip
"runpty doesn't simulate tty"
46 # Removing Version will trigger the welcome message. (setup_test
47 # inserted it so that other tests wouldn't show it.)
48 grep -v Version
"${context}" > "${context}.NEW"
49 mv -f "${context}.NEW" "${context}"
52 start_test
'mhparam skips the welcome message'
53 run_without_input mhparam path
54 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
55 # Make sure that version wasn't added to context.
56 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
60 start_test
'Welcome: disable in profile skips the welcome message'
61 cp "${MH}" "${MH}-welcome"
62 printf 'Welcome: disable\n' >> "${MH}-welcome"
63 # Run the function in subshell instead of augmenting the environment
64 # for a single command, so that the environment does not retain the
65 # MH setting. That can happen when run under distcheck, depending
66 # on the user's shell.
67 (MH
="${MH}-welcome"; run_without_input pick last
)
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
'with welcome message'
76 run_without_input pick last
77 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
78 # Make sure that version was added to context.
79 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
83 start_test
'without welcome message'
84 # After running the previous test, this one should not have
85 # the welcome message.
86 run_without_input pick last
87 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
88 # Make sure that version is still in context.
89 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
93 start_test
'with MHCONTEXT, welcome only if older'
94 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
95 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
96 run_without_input pick last
97 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
98 # And make sure that version did get updated in context.
99 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
103 start_test
"with MHCONTEXT doesn't welcome if newer"
104 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
105 run_without_input pick last
106 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
107 # And make sure that version didn't get updated in context.
108 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
112 start_test
'with MHCONTEXT but no version, no welcome and update'
113 printf '' >"${MHCONTEXT}"
114 run_without_input pick last
115 grep 'Welcome to nmh version ' "${actual}" >/dev
/null
&& false
116 # And make sure that version did get updated in context.
117 grep "^${version}$" "${MHCONTEXT}" >/dev
/null