]> diplodocus.org Git - nmh/blob - test/mhparam/test-mhparam
back out use of RFC 2047 decoding on the filename
[nmh] / test / mhparam / test-mhparam
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhparam
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 expected=$MH_TEST_DIR/$$.expected
20 expected_err=$MH_TEST_DIR/$$.expected_err
21 actual=$MH_TEST_DIR/$$.actual
22 actual_err=$MH_TEST_DIR/$$.actual_err
23
24
25 # check -help
26 cat >$expected <<EOF
27 Usage: mhparam [profile-components] [switches]
28 switches are:
29 -[no]components
30 -all
31 -version
32 -help
33 -(debug)
34 EOF
35
36 #### Skip nmh intro text.
37 mhparam -help | sed '/^$/,$d' >"$actual" 2>&1
38 check "$expected" "$actual"
39
40 # check -version
41 case `mhparam -v` in
42 mhparam\ --*) ;;
43 * ) echo "$0: mhparam -v generated unexpected output" 1>&2
44 failed=`expr ${failed:-0} + 1`;;
45 esac
46
47 # check unknown option
48 run_test 'mhparam -nonexistent' 'mhparam: -nonexistent unknown'
49
50 # check -all
51 cp "$MH" $expected
52 # -all adds current folder
53 echo 'Current-Folder: '`folder -f` >>$expected
54 run_prog mhparam -all >$actual
55 check $expected $actual 'keep first'
56
57 # check -all with a component
58 echo 'mhparam: profile-components ignored with -all' >$expected_err
59 run_prog mhparam -all path >$actual 2>$actual_err
60 check $expected $actual 'keep first'
61 check $expected_err $actual_err
62
63 # check -all with -components
64 echo 'mhparam: -components ignored with -all' >$expected_err
65 run_prog mhparam -all -components >$actual 2>$actual_err
66 check $expected $actual
67 check $expected_err $actual_err
68
69 # check one component
70 run_test 'mhparam path' "$MH_TEST_DIR/Mail"
71
72 # check more than one component, which enables -component
73 echo 'AliasFile: aliases' >>"$MH"
74 run_test 'mhparam path AliasFile' "path: $MH_TEST_DIR/Mail
75 AliasFile: aliases"
76
77 # check each component in procs array in uip/mhparam.c
78 # The tests don't override these, so they're default or configured values.
79 # Note that cat is hardcoded here because the testsuite uses it for moreproc.
80 cat >$expected <<EOF
81 context
82 .mh_sequences
83 $MH_INST_DIR$bindir/mhbuild
84 $MH_INST_DIR$bindir/refile
85 700
86 $bindir/inc
87 more
88 $MH_INST_DIR$bindir/mhmail
89 $MH_INST_DIR$nmhlibexecdir/mhl
90 cat
91 600
92 $bindir/packf
93 $MH_INST_DIR$nmhlibexecdir/post
94 $MH_INST_DIR$bindir/send
95 $MH_INST_DIR$bindir/mhshow
96 $MH_INST_DIR$nmhlibexecdir/mhl
97 nmh-`cat ${srcdir}/VERSION`
98 $MH_INST_DIR$bindir/whatnow
99 $MH_INST_DIR$bindir/whom
100 $nmhetcdirinst
101 $MH_LIBEXEC_DIR
102 fcntl
103 ${default_locking}
104 EOF
105
106 run_prog mhparam -nocomponent \
107 context \
108 mh-sequences \
109 buildmimeproc \
110 fileproc \
111 foldprot \
112 incproc \
113 lproc \
114 mailproc \
115 mhlproc \
116 moreproc \
117 msgprot \
118 packproc \
119 postproc \
120 sendproc \
121 showmimeproc \
122 showproc \
123 version \
124 whatnowproc \
125 whomproc \
126 etcdir \
127 libexecdir \
128 datalocking \
129 spoollocking >$actual 2>&1
130
131 check $expected $actual
132
133 #### This exits with non-zero status, so let run_test squash that:
134 run_test 'mhparam formatproc rmmproc' ''
135
136 #### Test sbackup separately because it's only passed as a -D compile option.
137 case `mhparam sbackup` in
138 ,|\#) ;;
139 * ) echo mhparam sbackup failed
140 failed=`expr ${failed:-0} + 1` ;;
141 esac
142
143 # check -component
144 run_test 'mhparam -component Path' "Path: $MH_TEST_DIR/Mail"
145
146 # check -component, note that component name of argument is echoed exactly
147 run_test 'mhparam -component path' "path: $MH_TEST_DIR/Mail"
148 run_test 'mhparam -component PATH' "PATH: $MH_TEST_DIR/Mail"
149
150 # check -nocomponent
151 run_test 'mhparam -component -nocomponent path' "$MH_TEST_DIR/Mail"
152 run_test 'mhparam -nocomponent path AliasFile' "$MH_TEST_DIR/Mail
153 aliases"
154
155 # check nonexistent component
156 run_test 'mhparam nonexistent' ''
157
158 # check that return status counts nonexistent components
159 set +e
160 mhparam path context nonexistent1 nonexistent2 nonexistent3 >/dev/null
161 run_test "echo $?" 3
162 set -e
163
164 # mhparam -debug
165 # Some of its output depends on configure options, so don't bother to
166 # check for correctness here.
167 mhparam -debug >/dev/null
168
169 # check with text file that does not end with newline
170 printf 'Editor: emacs' >>"$MH"
171 run_test 'mhparam -nocomponent editor' 'emacs'
172
173 exit $failed