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