File: test-version-check

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (101 lines) | stat: -rwxr-xr-x 3,356 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
######################################################
#
# Test display of new version welcome message.  This
# doesn't really belong in install-mh.
#
######################################################

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname $0`/../..
    MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi

. "${MH_OBJ_DIR}/test/common.sh"

setup_test
require_runpty_to_simulate_tty

actual="${MH_TEST_DIR}/test-version-check$$.actual"
context="${MH_TEST_DIR}"/Mail/context
version="Version: nmh-${MH_VERSION}"

# Removing Version will trigger the welcome message.  (setup_test
# inserted it so that other tests wouldn't show it.)
grep -v Version "${context}" > "${context}.NEW"
mv -f "${context}.NEW" "${context}"


start_test 'mhparam skips the welcome message'
run_without_input "${actual}" mhparam path
grep 'Welcome to nmh version ' "${actual}" >/dev/null  &&  false
# Make sure that version wasn't added to context.
grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null  &&  false
rm "${actual}"


start_test 'Welcome: disable in profile skips the welcome message'
cp "${MH}" "${MH}-welcome"
printf 'Welcome: disable\n' >> "${MH}-welcome"
# Run the function in subshell instead of augmenting the environment
# for a single command, so that the environment does not retain the
# MH setting.  That can happen when run under distcheck, depending
# on the user's shell.
(MH="${MH}-welcome"; run_without_input "${actual}" pick last)
rm "${MH}-welcome"
grep 'Welcome to nmh version ' "${actual}" >/dev/null  &&  false
# Make sure that version wasn't added to context.
grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null  &&  false
rm "${actual}"


start_test 'with welcome message'
run_without_input "${actual}" pick last
grep 'Welcome to nmh version ' "${actual}" >/dev/null
# Make sure that version was added to context.
grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
rm "${actual}"


start_test 'without welcome message'
# After running the previous test, this one should not have
# the welcome message.
run_without_input "${actual}" pick last
grep 'Welcome to nmh version ' "${actual}" >/dev/null  &&  false
# Make sure that version is still in context.
grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
rm "${actual}"


start_test 'with MHCONTEXT, welcome only if older'
MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
run_without_input "${actual}" pick last
grep 'Welcome to nmh version ' "${actual}" >/dev/null
# And make sure that version did get updated in context.
grep "^${version}$" "${MHCONTEXT}" >/dev/null
rm "${actual}"


start_test "with MHCONTEXT doesn't welcome if newer"
printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
run_without_input "${actual}" pick last
grep 'Welcome to nmh version ' "${actual}" >/dev/null  &&  false
# And make sure that version didn't get updated in context.
grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null
rm "${actual}"


start_test 'with MHCONTEXT but no version, no welcome and update'
printf '' >"${MHCONTEXT}"
run_without_input "${actual}" pick last
grep 'Welcome to nmh version ' "${actual}" >/dev/null  &&  false
# And make sure that version did get updated in context.
grep "^${version}$" "${MHCONTEXT}" >/dev/null
rm "${actual}"


finish_test
exit ${failed}