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