]> diplodocus.org Git - nmh/blob - test/install-mh/test-version-check
Replaced strtod() with strtof().
[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 -x # ???? debug on buildbot
10 set -e
11
12 if test -z "${MH_OBJ_DIR}"; then
13 srcdir=`dirname $0`/../..
14 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 fi
16
17 . "${MH_OBJ_DIR}/test/common.sh"
18
19 setup_test
20
21 require_prog script
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'
25 else
26 script_command_opt=''
27 fi
28
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.
31 run_without_input() {
32 echo MHCONTEXT = $MHCONTEXT # ????
33 if [ "$script_command_opt" = -c ]; then
34 #### -c takes single argument with command + arguments.
35 script -q -f -c "$*" "$actual" >/dev/null &
36 else
37 #### E.g., FreeBSD. Don't combine command arguments.
38 script -q -t 0 "$actual" "$@" >/dev/null &
39 fi
40
41 wait $!
42 }
43
44 actual="$MH_TEST_DIR/test-version-check$$.actual"
45 context="${MH_TEST_DIR}"/Mail/context
46 version="Version: nmh-${MH_VERSION}"
47
48 # Removing Version will trigger the welcome message. (setup_test
49 # inserted it so that other tests wouldn't show it.)
50 grep -v Version "$context" > "$context.NEW"
51 mv -f "$context.NEW" "$context"
52
53
54 start_test 'mhparam skips the welcome message'
55 run_without_input mhparam path
56 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
57 # Make sure that version wasn't added to context.
58 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
59 rm "$actual"
60
61
62 start_test 'Welcome: disable in profile skips the welcome message'
63 cp "${MH}" "${MH}-welcome"
64 printf 'Welcome: disable\n' >> "${MH}-welcome"
65 (MH="${MH}-welcome" run_without_input pick last)
66 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
67 # Make sure that version wasn't added to context.
68 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
69 rm "$actual"
70
71
72 start_test 'with welcome message'
73 run_without_input pick last
74 cat "${MH_TEST_DIR}/Mail/context"; cat "$actual" # ????
75 grep 'Welcome to nmh version ' "$actual" >/dev/null
76 # Make sure that version was added to context.
77 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
78 rm "$actual"
79
80
81 start_test 'without welcome message'
82 # After running the previous test, this one should not have
83 # the welcome message.
84 run_without_input pick last
85 grep 'Welcome to nmh version ' "$actual" >/dev/null && false
86 # Make sure that version is still in context.
87 grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
88 rm "$actual"
89
90
91 start_test 'with MHCONTEXT, welcome only if older'
92 MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
93 printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
94 cat "$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
99 rm "$actual"
100
101
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
108 rm "$actual"
109
110
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
117 rm "$actual"
118
119
120 finish_test
121 exit $failed