2 ######################################################
4 # Test display of new version welcome message. This
5 # doesn't really belong in install-mh.
7 ######################################################
9 set -x # ???? debug on buildbot
12 if test -z "${MH_OBJ_DIR}"; then
13 srcdir
=`dirname $0`/..
/..
14 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
17 .
"${MH_OBJ_DIR}/test/common.sh"
22 #### FreeBSD script, e.g., doesn't use -c to identify a command to run.
23 if script -c 'echo OK' /dev
/null
2>&1 | egrep 'OK' >/dev
/null
; then
24 script_command_opt
='-c'
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 if [ "$script_command_opt" = -c ]; then
33 #### -c takes single argument with command + arguments.
34 script -c "$*" -f -q "$actual" >/dev
/null
&
36 #### E.g., FreeBSD. Don't combine command arguments.
37 script -f -q "$actual" "$@" >/dev
/null
&
43 actual
="$MH_TEST_DIR/test-version-check$$.actual"
44 context
="${MH_TEST_DIR}"/Mail
/context
45 version
="Version: nmh-${MH_VERSION}"
47 # Removing Version will trigger the welcome message. (setup_test
48 # inserted it so that other tests wouldn't show it.)
49 grep -v Version
"$context" > "$context.NEW"
50 mv -f "$context.NEW" "$context"
53 start_test
'mhparam skips the welcome message'
54 run_without_input mhparam path
55 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
56 # Make sure that version wasn't added to context.
57 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
61 start_test
'Welcome: disable in profile skips the welcome message'
62 cp "${MH}" "${MH}-welcome"
63 printf 'Welcome: disable\n' >> "${MH}-welcome"
64 (MH
="${MH}-welcome" run_without_input pick last
)
65 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
66 # Make sure that version wasn't added to context.
67 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
71 start_test
'with welcome message'
72 run_without_input pick last
73 grep 'Welcome to nmh version ' "$actual" >/dev
/null
74 # Make sure that version was added to context.
75 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
79 start_test
'without welcome message'
80 # After running the previous test, this one should not have
81 # the welcome message.
82 run_without_input pick last
83 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
84 # Make sure that version is still in context.
85 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
89 start_test
'with MHCONTEXT, welcome only if older'
90 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
91 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
92 run_without_input pick last
93 grep 'Welcome to nmh version ' "$actual" >/dev
/null
94 # And make sure that version did get updated in context.
95 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
99 start_test
"with MHCONTEXT doesn't welcome if newer"
100 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
101 run_without_input pick last
102 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
103 # And make sure that version didn't get updated in context.
104 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
108 start_test
'with MHCONTEXT but no version, no welcome and update'
109 printf '' >"${MHCONTEXT}"
110 run_without_input pick last
111 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
112 # And make sure that version did get updated in context.
113 grep "^${version}$" "${MHCONTEXT}" >/dev
/null