]> diplodocus.org Git - nmh/blob - test/install-mh/test-version-check
Moved run_without_input() from test-version-check to common.sh.in.
[nmh] / test / install-mh / test-version-check
1 #!/bin/sh
2 ######################################################
3 #
4 # Test display of new version welcome message. This
5 # doesn't really belong in install-mh.
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname $0`/../..
13 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "${MH_OBJ_DIR}/test/common.sh"
17
18 setup_test
19 require_runpty_to_simulate_tty
20
21 actual="${MH_TEST_DIR}/test-version-check$$.actual"
22 context="${MH_TEST_DIR}"/Mail/context
23 version="Version: nmh-${MH_VERSION}"
24
25 # Removing Version will trigger the welcome message. (setup_test
26 # inserted it so that other tests wouldn't show it.)
27 grep -v Version "${context}" > "${context}.NEW"
28 mv -f "${context}.NEW" "${context}"
29
30
31 start_test 'mhparam skips the welcome message'
32 run_without_input "${actual}" mhparam path
33 grep 'Welcome to nmh version ' "${actual}" >/dev/null && false
34 # Make sure that version wasn't added to context.
35 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
36 rm "${actual}"
37
38
39 start_test 'Welcome: disable in profile skips the welcome message'
40 cp "${MH}" "${MH}-welcome"
41 printf 'Welcome: disable\n' >> "${MH}-welcome"
42 # Run the function in subshell instead of augmenting the environment
43 # for a single command, so that the environment does not retain the
44 # MH setting. That can happen when run under distcheck, depending
45 # on the user's shell.
46 (MH="${MH}-welcome"; run_without_input "${actual}" pick last)
47 rm "${MH}-welcome"
48 grep 'Welcome to nmh version ' "${actual}" >/dev/null && false
49 # Make sure that version wasn't added to context.
50 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
51 rm "${actual}"
52
53
54 start_test 'with welcome message'
55 run_without_input "${actual}" pick last
56 grep 'Welcome to nmh version ' "${actual}" >/dev/null
57 # Make sure that version was added to context.
58 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
59 rm "${actual}"
60
61
62 start_test 'without welcome message'
63 # After running the previous test, this one should not have
64 # the welcome message.
65 run_without_input "${actual}" pick last
66 grep 'Welcome to nmh version ' "${actual}" >/dev/null && false
67 # Make sure that version is still in context.
68 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
69 rm "${actual}"
70
71
72 start_test 'with MHCONTEXT, welcome only if older'
73 MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
74 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
75 run_without_input "${actual}" pick last
76 grep 'Welcome to nmh version ' "${actual}" >/dev/null
77 # And make sure that version did get updated in context.
78 grep "^${version}$" "${MHCONTEXT}" >/dev/null
79 rm "${actual}"
80
81
82 start_test "with MHCONTEXT doesn't welcome if newer"
83 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
84 run_without_input "${actual}" pick last
85 grep 'Welcome to nmh version ' "${actual}" >/dev/null && false
86 # And make sure that version didn't get updated in context.
87 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null
88 rm "${actual}"
89
90
91 start_test 'with MHCONTEXT but no version, no welcome and update'
92 printf '' >"${MHCONTEXT}"
93 run_without_input "${actual}" pick last
94 grep 'Welcome to nmh version ' "${actual}" >/dev/null && false
95 # And make sure that version did get updated in context.
96 grep "^${version}$" "${MHCONTEXT}" >/dev/null
97 rm "${actual}"
98
99
100 finish_test
101 exit ${failed}