]> diplodocus.org Git - nmh/blob - test/ali/test-ali
Expanded allowed text in mhical parse error message.
[nmh] / test / ali / test-ali
1 #!/bin/sh
2 ######################################################
3 #
4 # Test ali
5 #
6 ######################################################
7
8 # Not tested:
9 # -normalize, -nonormalize
10
11 set -e
12
13 if test -z "${MH_OBJ_DIR}"; then
14 srcdir=`dirname $0`/../..
15 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
16 fi
17
18 . "$MH_OBJ_DIR/test/common.sh"
19
20 setup_test
21
22 check_exit '-eq 1' ali -
23 check_exit '-eq 1' ali -noalias -alias
24 check_exit '-eq 1' ali -user
25 check_exit '-eq 1' ali -user ''
26 check_exit '-eq 1' ali -user 'foo bar'
27 check_exit '-eq 0' ali -user foo,bar
28
29 expected=$MH_TEST_DIR/$$.expected
30 expected_err=$MH_TEST_DIR/$$.expected_err
31 actual=$MH_TEST_DIR/$$.actual
32 actual_err=$MH_TEST_DIR/$$.actual_err
33
34
35 # check -help
36 start_test "-help"
37 cat >$expected <<EOF
38 Usage: ali [switches] aliases ...
39 switches are:
40 -alias aliasfile
41 -noalias
42 -[no]list
43 -[no]user
44 -version
45 -help
46 EOF
47
48 #### Skip nmh intro text.
49 ali -help 2>&1 | sed '/^$/,$d' >"$actual"
50 check "$expected" "$actual"
51
52 # check -version
53 start_test "-version"
54 case `ali -v` in
55 ali\ --*) ;;
56 * ) echo "$0: ali -v generated unexpected output" 1>&2
57 failed=`expr ${failed:-0} + 1`;;
58 esac
59
60 # check unknown option
61 start_test "unknown option"
62 run_test 'ali -nonexistent' 'ali: -nonexistent unknown'
63
64 # check with no arguments and no AliasFile profile component
65 start_test "with no arguments and no AliasFile profile component"
66 run_test 'ali' ''
67
68 # check with nonexistent alias file
69 start_test "with nonexistent alias file"
70 run_test 'ali -alias nonexistent' \
71 "ali: aliasing error in nonexistent - unable to read 'nonexistent'"
72
73 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
74 me: me@example.com
75 rush: geddy, alex, neil
76 geddy: geddy@example.com
77 alex: alex@example.com
78 neil: neil@example.com
79 EOF
80
81 # check -alias
82 start_test "-alias"
83 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases" \
84 'me: me@example.com
85 rush: geddy@example.com, alex@example.com, neil@example.com
86 geddy: geddy@example.com
87 alex: alex@example.com
88 neil: neil@example.com'
89
90 # check for a specific alias
91 start_test "for a specific alias"
92 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases rush" \
93 'geddy@example.com, alex@example.com, neil@example.com'
94
95 # check for a specific alias that doesn't exist
96 start_test "for a specific alias that doesn't exist"
97 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases nonexistent" \
98 'nonexistent'
99
100 # check -list
101 start_test "-list"
102 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases -list" \
103 'me: me@example.com
104 rush: geddy@example.com
105 alex@example.com
106 neil@example.com
107 geddy: geddy@example.com
108 alex: alex@example.com
109 neil: neil@example.com'
110
111 # check -nolist, which is the default
112 start_test "-nolist, which is the default"
113 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases -list -nolist" \
114 'me: me@example.com
115 rush: geddy@example.com, alex@example.com, neil@example.com
116 geddy: geddy@example.com
117 alex: alex@example.com
118 neil: neil@example.com'
119
120 # check -user
121 start_test "-user"
122 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases -user geddy@example.com" \
123 'rush, geddy'
124
125 # check -nouser
126 start_test "-nouser"
127 run_test \
128 "ali -alias ${MH_TEST_DIR}/Mail/aliases -user -nouser geddy@example.com" \
129 'geddy@example.com'
130
131 # check expansion of first address of blind list [Bug #15604]
132 start_test "expansion of first address of blind list [Bug #15604]"
133 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
134 rush: Rush: geddy, alex, neil
135 geddy: geddy@example.com
136 alex: alex@example.com
137 neil: neil@example.com
138 EOF
139
140 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases rush" \
141 'Rush: geddy@example.com, alex@example.com, neil@example.com'
142
143 # check that aliases followed by ; are not expanded [Bug #15604]
144 start_test "that aliases followed by ; are not expanded [Bug #15604]"
145 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
146 rush: Rush: geddy, alex, neil;
147 geddy: geddy@example.com
148 alex: alex@example.com
149 neil: neil@example.com
150 EOF
151
152 run_test "ali -alias ${MH_TEST_DIR}/Mail/aliases rush" \
153 'Rush: geddy@example.com, alex@example.com, neil;'
154
155 finish_test
156 exit $failed