File: test-comp-format

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (123 lines) | stat: -rwxr-xr-x 3,307 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
#
# Tests to see if the -from, -to, -cc, -fcc, and -subject switches to
# "comp" work correctly.
#

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' comp -
check_exit '-eq 1' comp -xyzzy
check_exit '-eq 0' comp -help
check_exit '-eq 0' comp -version
check_exit '-eq 1' comp -build -noedit -editor
check_exit '-eq 1' comp -whatnowproc
check_exit '-eq 1' comp -whatnowproc '' -
check_exit '-eq 1' comp -use -nouse -form
check_exit '-eq 1' comp -file
check_exit '-eq 1' comp -file foo -file
check_exit '-eq 1' comp -nodraftfolder -draftfolder
check_exit '-eq 1' comp -draftfolder foo -draftfolder
check_exit '-eq 1' comp -draftmessage
check_exit '-eq 1' comp -draftmessage foo -draftmessage
check_exit '-eq 1' comp -to
check_exit '-eq 1' comp -cc
check_exit '-eq 1' comp -from
check_exit '-eq 1' comp -fcc
check_exit '-eq 1' comp -fcc @ -
check_exit '-eq 1' comp -width
check_exit '-eq 1' comp -width 0
check_exit '-eq 1' comp -subject
check_exit '-eq 1' comp + @
check_exit '-eq 1' comp 42 314
check_exit '-eq 1' comp -form foo 42
check_exit '-eq 1' comp +
check_exit '-eq 1' comp 42

#
# Create a test template file (we create one here just in case the master
# one changes)
#

form="${MH_TEST_DIR}/$$.components"
cat > $form <<EOF
%(void{from})%(void(width))%(putaddr From: )
%(void{to})%(void(width))%(putaddr To: )
%(void{cc})%(void(width))%(putaddr cc: )
Fcc: %{fcc}
Subject: %{subject}
--------
EOF

expected="${MH_TEST_DIR}/$$.expected"
actual="${MH_TEST_DIR}/Mail/draft"
from="Mr Test User <test@example.com>"
to1="User One <userone@example.com>"
to2="User Two <usertwo@example.com>"
cc1="CC User One <ccuserone@example.com>"
cc2="CC User Two <ccusertwo@example.com>"
cc3="CC User Three <ccuserthree@example.com>"
cc4="CC User Four <ccuserfour@example.com>"
fcc1="+nosuchmailbox"
fcc2="+nosuchmailbox2"
subject="Totally bogus subject"

start_test 'check -from, -to, -cc, -fcc, and -subject switches'
cat > $expected <<EOF
From: ${from}
To: ${to1},
    ${to2}
cc: ${cc1},
    ${cc2},
    ${cc3},
    ${cc4}
Fcc: ${fcc1}, ${fcc2}
Subject: ${subject}
--------
EOF
run_prog \
comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
    -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
    -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
check "${expected}" "${actual}"


start_test 'check -fcc with no fcc in components'
cat > $form <<EOF
%<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
%<{to}%(void(width))%(putaddr To: )%|To:%>
%<{cc}%(void(width))%(putaddr cc: )%|cc:%>
Subject:%<{subject} %(putstr)%>
--------
EOF
#### There won't be an Fcc: header because there isn't one in the components.
cat > $expected <<EOF
From: ${from}
To: ${to1},
    ${to2}
cc: ${cc1},
    ${cc2},
    ${cc3},
    ${cc4}
Subject: ${subject}
--------
EOF

run_prog \
comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
    -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
    -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
check "${expected}" "${actual}"


test "${failed:-0}" -eq 0 && rm "${form}"

finish_test
exit $failed