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
|
#!/bin/sh
######################################################
#
# Test packf
#
######################################################
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' packf -
expected="$MH_TEST_DIR/$$.expected"
actual="$MH_TEST_DIR/$$.actual"
# check -help
start_test "-help"
cat >"$expected" <<EOF
Usage: packf [+folder] [msgs] [switches]
switches are:
-file name
-mbox
-mmdf
-version
-help
EOF
#### Skip nmh intro text.
packf -help 2>&1 | sed '/^$/,$d' >"$actual"
check "$expected" "$actual"
# check -version
start_test "-version"
case `packf -v` in
packf\ --*) ;;
* ) printf '%s: packf -v generated unexpected output\n' "$0" >&2
failed=`expr ${failed:-0} + 1`;;
esac
# check unknown switch
start_test "unknown switch"
run_test "packf -nonexistent" 'packf: -nonexistent unknown'
cd "${MH_TEST_DIR}" || exit 1
printf 'y\n' >Mail/yes
# check with no switches
start_test "with no switches"
rm -f msgbox
run_prog packf <Mail/yes
inc +inbox2 -file msgbox <Mail/yes >/dev/null
rm -f msgbox
for i in `pick +inbox`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
# check +folder
start_test "+folder"
run_prog packf +inbox <Mail/yes
inc +inbox2 -file msgbox >/dev/null
rm -f msgbox
for i in `pick +inbox`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
# check msgs
start_test "msgs"
run_prog packf +inbox 1 2 3 <Mail/yes
inc +inbox2 -file msgbox >/dev/null
rm -f msgbox
for i in `pick +inbox2`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '3'
rmm +inbox2 -unlink `pick +inbox2`
# check -file
start_test "-file"
rm -f msgbox2
run_prog packf +inbox -file msgbox2 <Mail/yes
inc +inbox2 -file msgbox2 >/dev/null
for i in `pick +inbox2`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
# check append to existing mbox file
start_test "append to existing mbox file"
run_prog packf +inbox -file msgbox2 <Mail/yes
inc +inbox2 -file msgbox2 >/dev/null
rm -f msgbox2
for i in `pick +inbox2`; do
if [ $i -le 10 ]; then
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
else
arith_eval $i - 10
diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
fi
done
run_test "printf $i" '20'
rmm +inbox2 -unlink `pick +inbox2`
# check -mbox
start_test "-mbox"
run_prog packf +inbox -mbox <Mail/yes
inc +inbox2 -file msgbox >/dev/null
rm -f msgbox
for i in `pick +inbox2`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
# check -mmdf
start_test "-mmdf"
run_prog packf +inbox -mmdf <Mail/yes
inc +inbox2 -file msgbox >/dev/null
rm -f msgbox
for i in `pick +inbox2`; do
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
# check append to existing mmdf file
start_test "append to existing mmdf file"
run_prog packf +inbox -mmdf <Mail/yes
inc +inbox2 -file msgbox >/dev/null
rm -f msgbox
for i in `pick +inbox2`; do
if [ $i -le 10 ]; then
diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
else
arith_eval $i - 10
diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
fi
done
run_test "printf $i" '10'
rmm +inbox2 -unlink `pick +inbox2`
finish_test
exit ${failed:-0}
|