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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
#!/bin/sh
######################################################
#
# Test prompter
#
######################################################
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
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
cat >$expected <<EOF
Usage: prompter [switches] file
switches are:
-erase chr
-kill chr
-[no]prepend
-[no]rapid
-[no]doteof
-version
-help
EOF
run_prog prompter -help >$actual 2>&1
check $expected $actual
# check -version
case `prompter -v` in
prompter\ --*) ;;
* ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2
failed=`expr ${failed:-0} + 1`;;
esac
# check unknown switch
run_test 'prompter -nonexistent' 'prompter: -nonexistent unknown'
# check with no switches
run_test 'prompter' 'prompter: usage: prompter [switches] file'
# check with file
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------
message body
EOF
cat >$MH_TEST_DIR/prompter-file <<EOF
Resent-From: sender@example.com
Resent-To:
Resent-cc:
Resent-fcc:
EOF
printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n' | \
run_prog prompter $MH_TEST_DIR/prompter-file >/dev/null
check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first'
# check -doteof
cat >$MH_TEST_DIR/prompter-file <<EOF
Resent-From: sender@example.com
Resent-To:
Resent-cc:
Resent-fcc:
EOF
printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n.\n' | \
run_prog prompter -doteof $MH_TEST_DIR/prompter-file >/dev/null
check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first'
# check -nodoteof
cat >$MH_TEST_DIR/prompter-file <<EOF
Resent-From: sender@example.com
Resent-To:
Resent-cc:
Resent-fcc:
EOF
printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n' | \
run_prog prompter -doteof -nodoteof $MH_TEST_DIR/prompter-file >/dev/null
check "$expected" "$MH_TEST_DIR/prompter-file" 'keep first'
# check -noprepend
cat >$MH_TEST_DIR/prompter-file <<EOF
Resent-From: sender@example.com
Resent-To:
Resent-cc:
Resent-fcc:
--------
message body
EOF
printf 'appendage\n' >>"$expected"
printf 'recipient@example.com\ncc@example.com\n+outbox\nappendage\n' | \
run_prog prompter -noprepend $MH_TEST_DIR/prompter-file >/dev/null
check "$expected" "$MH_TEST_DIR/prompter-file"
# check -prepend
cat >$MH_TEST_DIR/prompter-file <<EOF
Resent-From: sender@example.com
Resent-To:
Resent-cc:
Resent-fcc:
--------
message body
EOF
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------
prependage
message body
EOF
printf 'recipient@example.com\ncc@example.com\n+outbox\nprependage\n' | \
run_prog prompter -noprepend -prepend $MH_TEST_DIR/prompter-file >/dev/null
check "$MH_TEST_DIR/prompter-file" "$expected" 'keep first'
# check -rapid
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------Enter initial text
--------
EOF
run_prog prompter -rapid $MH_TEST_DIR/prompter-file >"$actual" </dev/null
check "$expected" "$actual"
# check -norapid
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------Enter initial text
prependage
message body
--------
EOF
run_prog prompter -rapid -norapid $MH_TEST_DIR/prompter-file \
>"$actual" </dev/null
check "$expected" "$actual"
# check -erase and -kill. We can't test their effects because they
# only affect the terminal and this test execution might not be
# connected to one. So we can just check that the respective options
# were set.
cat >$expected <<EOF
erase ^U, kill ^?, intr ^@
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------Enter initial text
prependage
message body
--------
EOF
printf 'woot woot\n' | \
run_prog prompter -erase '' -kill '' $MH_TEST_DIR/prompter-file >"$actual"
check "$expected" "$actual"
# check -body. It's undocumented but the default, so make sure that
# it reverses the effect of -nobody.
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
--------Enter initial text
woot woot
prependage
message body
--------
EOF
run_prog prompter -nobody -body $MH_TEST_DIR/prompter-file >"$actual" \
</dev/null
check "$expected" "$actual"
# check -nobody. It's undocumented but looks like it removes the body.
cat >$expected <<EOF
Resent-From: sender@example.com
Resent-To: recipient@example.com
Resent-cc: cc@example.com
Resent-fcc: +outbox
EOF
run_prog prompter -nobody $MH_TEST_DIR/prompter-file >/dev/null
check "$expected" "$MH_TEST_DIR/prompter-file"
exit ${failed:-0}
|