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