Fix tests/mhparam/test-mhparam
[mmh] / test / tests / mhparam / test-mhparam
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhparam
5 #
6 ######################################################
7
8
9 . "$MH_TEST_COMMON"
10
11
12 # check -help
13 runandcheck "mhparam -help" <<!
14 Usage: mhparam [profile-components] [switches]
15   switches are:
16   -[no]components
17   -all
18   -Version
19   -help
20 !
21
22
23 # check -version
24 case `mhparam -V` in
25   mhparam\ --*) ;;
26   *           ) echo "$0: mhparam -v generated unexpected output" 1>&2
27                 failed=`expr ${failed:-0} + 1`;;
28 esac
29
30 # check unknown option
31 runandcheck 'mhparam -nonexistent' <<!
32 mhparam: -nonexistent unknown
33 !
34
35 # check -all
36 cp "$MMH/profile" "$MMH/profile2"
37
38 MMHP="$MMH/profile2"
39 export MMHP
40
41 # -all adds current folder
42 runandcheck "mhparam -all" <<!
43 Path: $MH_TEST_DIR/Mail
44 Inbox: +inbox
45 Current-Folder: inbox
46 !
47
48
49 # check -all with a component
50 runandcheck "mhparam -all path >/dev/null" <<!
51 mhparam: profile-components ignored with -all
52 !
53
54 # check -all with -components
55 runandcheck "mhparam -all -components >/dev/null" <<!
56 mhparam: -components ignored with -all
57 !
58
59 # check one component
60 runandcheck 'mhparam path' <<!
61 $MH_TEST_DIR/Mail
62 !
63
64 # check more than one component, which enables -component
65 echo 'AliasFile: aliases' >>"$MMHP"
66 runandcheck 'mhparam path AliasFile' <<!
67 path: $MH_TEST_DIR/Mail
68 AliasFile: aliases
69 !
70
71
72 #### This exits with non-zero status, so let runandcheck squash that:
73 runandcheck 'mhparam formatproc rmmproc' <<!
74 !
75
76
77 # check -component
78 runandcheck 'mhparam -component Path' <<!
79 Path: $MH_TEST_DIR/Mail
80 !
81
82 # check -component, note that component name of argument is echoed exactly
83 runandcheck 'mhparam -component path' <<!
84 path: $MH_TEST_DIR/Mail
85 !
86 runandcheck 'mhparam -component PATH' <<!
87 PATH: $MH_TEST_DIR/Mail
88 !
89
90 # check -nocomponent
91 runandcheck 'mhparam -component -nocomponent path' <<!
92 $MH_TEST_DIR/Mail
93 !
94 runandcheck 'mhparam -nocomponent path AliasFile' <<!
95 $MH_TEST_DIR/Mail
96 aliases
97 !
98
99
100 # check nonexistent component
101 runandcheck 'mhparam nonexistent' <<!
102 !
103
104
105 # check that return status counts nonexistent components
106 runandcheck "mhparam path context nonexistent1 nonexistent2 \
107                 nonexistent3 >/dev/null; echo \$?" <<!
108 3
109 !
110 # check that return status counts nonexistent components
111 runandcheck "mhparam path context nonexistent1 nonexistent2 \
112                 nonexistent3 inbox >/dev/null; echo \$?" <<!
113 3
114 !
115
116 # mhparam -debug
117 # Some of its output depends on configure options, so don't bother to
118 # check for correctness here.
119 runandcheck "mhparam -debug >/dev/null; echo \$?" <<!
120 0
121 !
122
123 # check with folded header
124 cat >>"$MMHP" <<!
125 Alternate-Mailboxes: alice@example.org,
126   bob@example.net,
127         charly@example.comp
128 !
129 runandcheck 'mhparam alternate-mailboxes' <<!
130 alice@example.org,   bob@example.net,  charly@example.comp
131 !
132
133
134 # check with text file that does not end with newline
135 # in mmh this is invalid
136 printf 'Editor: emacs' >>"$MMHP"
137 export VISUAL=ed
138 runandcheck 'mhparam -nocomponent editor' <<!
139 mhparam: `cat test-temp-dir`/.mmh/profile2 is poorly formatted
140 $VISUAL
141 !
142 unset VISUAL
143
144
145 exit
146
147 # FIXME: needs to be adjusted or removed ...
148
149 # check each component in procs array in uip/mhparam.c
150 # The tests don't override these, so they're default or configured values.
151 # Note that cat is hardcoded here because the testsuite uses it for moreproc.
152
153 runandcheck "mhparam -nocomponent \
154                 context \
155                 mh-sequences \
156                 buildmimeproc \
157                 fileproc \
158                 foldprot \
159                 incproc \
160                 lproc \
161                 mailproc \
162                 mhlproc \
163                 moreproc \
164                 msgprot \
165                 packproc \
166                 postproc \
167                 sendproc \
168                 showmimeproc \
169                 showproc \
170                 version \
171                 whatnowproc \
172                 whomproc \
173                 etcdir \
174                 libexecdir \
175                 datalocking \
176                 spoollocking" <<!
177 context
178 .mh_sequences
179 $MH_INST_DIR$bindir/mhbuild
180 $MH_INST_DIR$bindir/refile
181 700
182 $bindir/inc
183 more
184 $MH_INST_DIR$bindir/mhmail
185 $MH_INST_DIR$nmhlibexecdir/mhl
186 cat
187 600
188 $bindir/packf
189 $MH_INST_DIR$nmhlibexecdir/post
190 $MH_INST_DIR$bindir/send
191 $MH_INST_DIR$bindir/mhshow
192 $MH_INST_DIR$nmhlibexecdir/mhl
193 nmh-`cat ${srcdir}/VERSION`
194 $MH_INST_DIR$bindir/whatnow
195 $MH_INST_DIR$bindir/whom
196 $nmhetcdirinst
197 $MH_LIBEXEC_DIR
198 fcntl
199 ${default_locking}
200 !
201