]> diplodocus.org Git - nmh/blob - test/install-mh/test-version-check
Updated comments in h/prototypes.h.
[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
20 require_prog script
21
22 actual="$MH_TEST_DIR/test-version-check$$.actual"
23 context="${MH_TEST_DIR}"/Mail/context
24 version="Version: nmh-${MH_VERSION}"
25
26 # Removing Version will trigger the welcome message. (setup_test
27 # inserted it so that other tests wouldn't show it.)
28 grep -v Version "$context" > "$context.NEW"
29 mv -f "$context.NEW" "$context"
30
31
32 start_test 'mhparam skips the welcome message'
33 # The command will wait for the user to hit return. script seems to do what
34 # we want by not waiting when run in the background.
35 script -c 'mhparam path last' -f -q "$actual" >/dev/null &
36 wait $!
37 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
38 rm "$actual"
39 # Make sure that version wasn't added to context.
40 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
41 finish_test
42
43
44 start_test 'Welcome: disable in profile skips the welcome message'
45 cp "${MH}" "${MH}-welcome"
46 printf 'Welcome: disable\n' >> "${MH}-welcome"
47 MH="${MH}-welcome" script -c 'pick last' -f -q "$actual" >/dev/null &
48 wait $!
49 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
50 rm "$actual"
51 # Make sure that version wasn't added to context.
52 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
53 finish_test
54
55
56 start_test 'with welcome message'
57 script -c 'pick last' -f -q "$actual" >/dev/null &
58 wait $!
59 grep 'Welcome to nmh version ' "$actual" >/dev/null
60 rm "$actual"
61 # Make sure that version was added to context.
62 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
63 finish_test
64
65
66 start_test 'without welcome message'
67 # After running the previous test, this one should not have
68 # the welcome message.
69 script -c 'pick last' -f -q "$actual" >/dev/null &
70 wait $!
71 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
72 rm "$actual"
73 # Make sure that version is still in context.
74 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
75 finish_test
76
77
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 script -c 'pick last' -f -q "$actual" >/dev/null &
82 wait $!
83 grep 'Welcome to nmh version ' "$actual" >/dev/null
84 # And make sure that version did get updated in context.
85 grep "^${version}$" "${MHCONTEXT}" >/dev/null
86 rm "$actual"
87 finish_test
88
89
90 start_test "with MHCONTEXT doesn't welcome if newer"
91 printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
92 script -c 'pick last' -f -q "$actual" >/dev/null &
93 wait $!
94 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
95 rm "$actual"
96 # And make sure that version didn't get updated in context.
97 grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null
98 finish_test
99
100
101 start_test 'with MHCONTEXT but no version, no welcome and update'
102 printf '' >"${MHCONTEXT}"
103 script -c 'pick last' -f -q "$actual" >/dev/null &
104 wait $!
105 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
106 # And make sure that version did get updated in context.
107 grep "^${version}$" "${MHCONTEXT}" >/dev/null
108 rm "$actual"
109 finish_test
110
111
112 exit $failed