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