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"
21 if script -S /bin
/sh
'echo OK' /dev
/null
2>&1 | egrep 'OK' >/dev
/null
; then
22 #### script(1) uses -S to set the shell that it runs.
25 #### Assume that script(1) uses SHELL environment variable.
29 #### Run a command but don't wait for user input. script(1) seems to do
30 #### what we want by not waiting when run in the background.
32 #### Create a command to use as a shell for script.
39 if [ ${use_dash_S} -eq 1 ]; then
40 script -S "${cmd}" "$actual" >/dev
/null
&
42 SHELL
="${cmd}" script "$actual" >/dev
/null
&
48 actual
="$MH_TEST_DIR/test-version-check$$.actual"
49 context
="${MH_TEST_DIR}"/Mail
/context
50 version
="Version: nmh-${MH_VERSION}"
51 cmd
="${MH_TEST_DIR}/Mail/cmd"
53 # Removing Version will trigger the welcome message. (setup_test
54 # inserted it so that other tests wouldn't show it.)
55 grep -v Version
"$context" > "$context.NEW"
56 mv -f "$context.NEW" "$context"
59 start_test
'mhparam skips the welcome message'
60 run_without_input mhparam path
61 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
62 # Make sure that version wasn't added to context.
63 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
67 start_test
'Welcome: disable in profile skips the welcome message'
68 cp "${MH}" "${MH}-welcome"
69 printf 'Welcome: disable\n' >> "${MH}-welcome"
70 # Run the function in subshell instead of augmenting the environment
71 # for a single command, so that the environment does not retain the
72 # MH setting. That can happen when run under distcheck, depending
73 # on the user's shell.
74 (MH
="${MH}-welcome"; run_without_input pick last
)
76 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
77 # Make sure that version wasn't added to context.
78 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
82 start_test
'with welcome message'
83 echo MH
="${MH}" # ???? debug
84 run_without_input pick last
85 cat "$actual" # ???? debug
86 grep 'Welcome to nmh version ' "$actual" >/dev
/null
87 # Make sure that version was added to context.
88 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
92 start_test
'without welcome message'
93 # After running the previous test, this one should not have
94 # the welcome message.
95 run_without_input pick last
96 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
97 # Make sure that version is still in context.
98 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
102 start_test
'with MHCONTEXT, welcome only if older'
103 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
104 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
105 run_without_input pick last
106 grep 'Welcome to nmh version ' "$actual" >/dev
/null
107 # And make sure that version did get updated in context.
108 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
112 start_test
"with MHCONTEXT doesn't welcome if newer"
113 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
114 run_without_input pick last
115 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
116 # And make sure that version didn't get updated in context.
117 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
121 start_test
'with MHCONTEXT but no version, no welcome and update'
122 printf '' >"${MHCONTEXT}"
123 run_without_input pick last
124 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
125 # And make sure that version did get updated in context.
126 grep "^${version}$" "${MHCONTEXT}" >/dev
/null