2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 . "$MH_OBJ_DIR/test/common.sh"
19 # Use proper program, likely not the first one on PATH.
22 expected="$MH_TEST_DIR/$$.expected"
23 expected_err="$MH_TEST_DIR/$$.expected_err"
24 actual="$MH_TEST_DIR/$$.actual"
25 actual_err="$MH_TEST_DIR/$$.actual_err"
29 cat >"$expected" <<EOF
30 Usage: dp [switches] dates ...
39 $dp -help >"$actual" 2>&1
40 check "$expected" "$actual"
45 * ) printf '%s: dp -v generated unexpected output\n' "$0" >&2
46 failed=`expr ${failed:-0} + 1`;;
49 # check unknown switch
50 run_test "$dp -nonexistent" 'dp: -nonexistent unknown'
52 # check with no switches
53 run_test "$dp" 'dp: usage: dp [switches] dates ...'
55 # check with one valid date
56 cat >"$expected" <<EOF
57 Sun, 01 Jul 2012 00:00:00
60 $dp 'Sun Jul 1 2012' > "$actual" 2>&1
61 check "$expected" "$actual"
63 # check with two valid dates
64 cat >"$expected" <<EOF
65 Sun, 01 Jul 2012 00:00:00
66 Mon, 02 Jul 2012 00:00:00
69 $dp 'Sun Jul 1 2012' 'Mon Jul 2 2012' > "$actual" 2>&1
70 check "$expected" "$actual"
72 # check with invalid date
73 cat >"$expected" <<EOF
77 cat >"$expected_err" <<EOF
80 $dp 'not a date' > "$actual" 2> "$actual_err"
81 check "$expected" "$actual"
82 check "$expected_err" "$actual_err"
85 form="${MH_TEST_DIR}/Mail/dp-form"
90 cat >"$expected" <<EOF
94 $dp -form "$form" 'Jul 1 2012' >$actual 2>&1
95 check $expected $actual
99 cat >"$expected" <<EOF
103 $dp -format '%(day{text})' 'Jul 1 2012' >$actual 2>&1
104 check $expected $actual
107 cat >"$expected" <<EOF
111 $dp -width 17 'Sun Jul 1 2012' > "$actual" 2>&1
112 check "$expected" "$actual"