]>
diplodocus.org Git - nmh/blob - test/install-mh/test-version-check
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 test -t 0 && echo stdin connected
|| echo stdin not connected
22 test -t 1 && echo stdout connected
|| echo stdout not connected
23 test -t 2 && echo stderr connected
|| echo stderr not connected
27 #### Use minimal arguments to script(1), i.e., just the file in
28 #### which to save the output. We do pipe input to script, which is
29 #### discouraged by the NOTES and BUGS sections of its man page.
30 #### But that seems to work.
32 actual
="$MH_TEST_DIR/test-version-check$$.actual"
33 context
="${MH_TEST_DIR}"/Mail
/context
34 version
="Version: nmh-${MH_VERSION}"
36 # Removing Version will trigger the welcome message. (setup_test
37 # inserted it so that other tests wouldn't show it.)
38 grep -v Version
"$context" > "$context.NEW"
39 mv -f "$context.NEW" "$context"
42 start_test
'mhparam skips the welcome message'
43 printf 'mhparam path\nexit\n' | script "$actual" >/dev
/null
44 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
45 # Make sure that version wasn't added to context.
46 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
&& false
50 start_test
'Welcome: disable in profile skips the welcome message'
51 cp "${MH}" "${MH}-welcome"
52 printf 'Welcome: disable\n' >> "${MH}-welcome"
53 (printf 'pick last\nexit\n' | MH
="${MH}-welcome" script "$actual" >/dev
/null
)
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
'with welcome message'
61 printf 'pick last\nexit\n' | script "$actual" >/dev
/null
62 grep 'Welcome to nmh version ' "$actual" >/dev
/null
63 # Make sure that version was added to context.
64 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
68 start_test
'without welcome message'
69 # After running the previous test, this one should not have
70 # the welcome message.
71 printf 'pick last\nexit\n' | script "$actual" >/dev
/null
72 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
73 # Make sure that version is still in context.
74 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev
/null
78 start_test
'with MHCONTEXT, welcome only if older'
79 MHCONTEXT
="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
80 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
81 printf 'pick last\nexit\n' | script "$actual" >/dev
/null
82 grep 'Welcome to nmh version ' "$actual" >/dev
/null
83 # And make sure that version did get updated in context.
84 grep "^${version}$" "${MHCONTEXT}" >/dev
/null
88 start_test
"with MHCONTEXT doesn't welcome if newer"
89 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
90 printf 'pick last\nexit\n' | script "$actual" >/dev
/null
91 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
92 # And make sure that version didn't get updated in context.
93 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev
/null
97 start_test
'with MHCONTEXT but no version, no welcome and update'
98 printf '' >"${MHCONTEXT}"
99 printf 'pick last\nexit\n' | script "$actual" >/dev
/null
100 grep 'Welcome to nmh version ' "$actual" >/dev
/null
&& false
101 # And make sure that version did get updated in context.
102 grep "^${version}$" "${MHCONTEXT}" >/dev
/null