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 if test ! -t 0 || test ! -t 1 || test ! -t 2; then
21 test_skip 'must be connected to terminal'
25 #### FreeBSD script, e.g., doesn't use -c to identify a command to run.
26 if script -c 'echo OK' /dev/null 2>&1 | egrep 'OK' >/dev/null; then
27 script_command_opt='-c'
32 #### Run a command but don't wait for user input. script(1) seems to do
33 #### what we want by not waiting when run in the background.
35 if [ "$script_command_opt" = -c ]; then
36 #### -c takes single argument with command + arguments.
37 script -q -f -c "$*" "$actual" >/dev/null &
39 #### E.g., FreeBSD. Don't combine command arguments.
40 script -q -t 0 "$actual" "$@" >/dev/null &
46 actual="$MH_TEST_DIR/test-version-check$$.actual"
47 context="${MH_TEST_DIR}"/Mail/context
48 version="Version: nmh-${MH_VERSION}"
50 # Removing Version will trigger the welcome message. (setup_test
51 # inserted it so that other tests wouldn't show it.)
52 grep -v Version "$context" > "$context.NEW"
53 mv -f "$context.NEW" "$context"
56 start_test 'mhparam skips the welcome message'
57 run_without_input mhparam path
58 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
59 # Make sure that version wasn't added to context.
60 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
64 start_test 'Welcome: disable in profile skips the welcome message'
65 cp "${MH}" "${MH}-welcome"
66 printf 'Welcome: disable\n' >> "${MH}-welcome"
67 (MH="${MH}-welcome" run_without_input pick last)
68 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
69 # Make sure that version wasn't added to context.
70 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
74 start_test 'with welcome message'
75 run_without_input pick last
76 grep 'Welcome to nmh version ' "$actual" >/dev/null
77 # Make sure that version was added to context.
78 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
82 start_test 'without welcome message'
83 # After running the previous test, this one should not have
84 # the welcome message.
85 run_without_input pick last
86 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
87 # Make sure that version is still in context.
88 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
92 start_test 'with MHCONTEXT, welcome only if older'
93 MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
94 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
95 run_without_input pick last
96 grep 'Welcome to nmh version ' "$actual" >/dev/null
97 # And make sure that version did get updated in context.
98 grep "^${version}$" "${MHCONTEXT}" >/dev/null
102 start_test "with MHCONTEXT doesn't welcome if newer"
103 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
104 run_without_input pick last
105 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
106 # And make sure that version didn't get updated in context.
107 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null
111 start_test 'with MHCONTEXT but no version, no welcome and update'
112 printf '' >"${MHCONTEXT}"
113 run_without_input pick last
114 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
115 # And make sure that version did get updated in context.
116 grep "^${version}$" "${MHCONTEXT}" >/dev/null