7f21be3a5a94277d44ecd934684fb06a7c9d6e8e
[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 runandcheck 'mhparam -nocomponent editor' <<!
138 mhparam: `cat test-temp-dir`/.mmh/profile2 is poorly formatted
139 !
140
141
142 exit
143
144 # FIXME: needs to be adjusted or removed ...
145
146 # check each component in procs array in uip/mhparam.c
147 # The tests don't override these, so they're default or configured values.
148 # Note that cat is hardcoded here because the testsuite uses it for moreproc.
149
150 runandcheck "mhparam -nocomponent \
151                 context \
152                 mh-sequences \
153                 buildmimeproc \
154                 fileproc \
155                 foldprot \
156                 incproc \
157                 lproc \
158                 mailproc \
159                 mhlproc \
160                 moreproc \
161                 msgprot \
162                 packproc \
163                 postproc \
164                 sendproc \
165                 showmimeproc \
166                 showproc \
167                 version \
168                 whatnowproc \
169                 whomproc \
170                 etcdir \
171                 libexecdir \
172                 datalocking \
173                 spoollocking" <<!
174 context
175 .mh_sequences
176 $MH_INST_DIR$bindir/mhbuild
177 $MH_INST_DIR$bindir/refile
178 700
179 $bindir/inc
180 more
181 $MH_INST_DIR$bindir/mhmail
182 $MH_INST_DIR$nmhlibexecdir/mhl
183 cat
184 600
185 $bindir/packf
186 $MH_INST_DIR$nmhlibexecdir/post
187 $MH_INST_DIR$bindir/send
188 $MH_INST_DIR$bindir/mhshow
189 $MH_INST_DIR$nmhlibexecdir/mhl
190 nmh-`cat ${srcdir}/VERSION`
191 $MH_INST_DIR$bindir/whatnow
192 $MH_INST_DIR$bindir/whom
193 $nmhetcdirinst
194 $MH_LIBEXEC_DIR
195 fcntl
196 ${default_locking}
197 !
198