| 1 |
#!/bin/sh |
| 2 |
###################################################### |
| 3 |
# |
| 4 |
# Basic mhbuild tests. |
| 5 |
# |
| 6 |
###################################################### |
| 7 |
|
| 8 |
if test -z "${MH_OBJ_DIR}"; then |
| 9 |
srcdir=`dirname "$0"`/../.. |
| 10 |
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR |
| 11 |
fi |
| 12 |
|
| 13 |
. "$MH_OBJ_DIR/test/common.sh" |
| 14 |
|
| 15 |
setup_test |
| 16 |
|
| 17 |
expected="$MH_TEST_DIR/test-mhbuild$$.expected" |
| 18 |
|
| 19 |
start_test "-nodirectives" |
| 20 |
cat >"$expected" <<'EOF' |
| 21 |
Subject: test -nodirectives |
| 22 |
MIME-Version: 1.0 |
| 23 |
Content-Type: text/plain; charset="us-ascii" |
| 24 |
|
| 25 |
#define line begins with # and ends with backslash-newline \ |
| 26 |
all characters should be preserved |
| 27 |
EOF |
| 28 |
|
| 29 |
cat >"`mhpath new`" <<'EOF' |
| 30 |
Subject: test -nodirectives |
| 31 |
-------- |
| 32 |
#define line begins with # and ends with backslash-newline \ |
| 33 |
all characters should be preserved |
| 34 |
EOF |
| 35 |
|
| 36 |
run_test "mhbuild -nodirectives `mhpath last`" |
| 37 |
check "`mhpath last`" "$expected" |
| 38 |
|
| 39 |
start_test "Checking for MIME-Version handling in draft" |
| 40 |
|
| 41 |
cat > "`mhpath new`" <<'EOF' |
| 42 |
From: Somebody <[email protected]> |
| 43 |
To: Nobody <[email protected]> |
| 44 |
Subject: Test message |
| 45 |
MIME-Version: 1.0 |
| 46 |
-------- |
| 47 |
This is a test |
| 48 |
EOF |
| 49 |
|
| 50 |
cat >"$expected" <<'EOF' |
| 51 |
From: Somebody <[email protected]> |
| 52 |
To: Nobody <[email protected]> |
| 53 |
Subject: Test message |
| 54 |
MIME-Version: 1.0 |
| 55 |
-------- |
| 56 |
This is a test |
| 57 |
EOF |
| 58 |
|
| 59 |
run_test "mhbuild `mhpath last`" "mhbuild: draft shouldn't contain MIME-Version: field" |
| 60 |
check "`mhpath last`" "$expected" 'keep first' |
| 61 |
|
| 62 |
cat >"$expected" <<'EOF' |
| 63 |
From: Somebody <[email protected]> |
| 64 |
To: Nobody <[email protected]> |
| 65 |
Subject: Test message |
| 66 |
MIME-Version: 1.0 |
| 67 |
-------- |
| 68 |
This is a test |
| 69 |
EOF |
| 70 |
|
| 71 |
run_test "mhbuild -auto `mhpath last`" |
| 72 |
check "`mhpath last`" "$expected" |
| 73 |
|
| 74 |
start_test "Checking for arbitrary Content header handling in draft" |
| 75 |
|
| 76 |
cat > "`mhpath new`" <<'EOF' |
| 77 |
From: Somebody <[email protected]> |
| 78 |
To: Nobody <[email protected]> |
| 79 |
Subject: Test message |
| 80 |
Content-Fart: nothing |
| 81 |
-------- |
| 82 |
This is a test |
| 83 |
EOF |
| 84 |
|
| 85 |
cat >"$expected" <<'EOF' |
| 86 |
From: Somebody <[email protected]> |
| 87 |
To: Nobody <[email protected]> |
| 88 |
Subject: Test message |
| 89 |
Content-Fart: nothing |
| 90 |
-------- |
| 91 |
This is a test |
| 92 |
EOF |
| 93 |
|
| 94 |
run_test "mhbuild `mhpath last`" "mhbuild: draft shouldn't contain Content-Fart: field" |
| 95 |
check "`mhpath last`" "$expected" 'keep first' |
| 96 |
|
| 97 |
cat >"$expected" <<'EOF' |
| 98 |
From: Somebody <[email protected]> |
| 99 |
To: Nobody <[email protected]> |
| 100 |
Subject: Test message |
| 101 |
Content-Fart: nothing |
| 102 |
-------- |
| 103 |
This is a test |
| 104 |
EOF |
| 105 |
|
| 106 |
run_test "mhbuild -auto `mhpath last`" "mhbuild: draft shouldn't contain Content-Fart: field" |
| 107 |
check "`mhpath last`" "$expected" |
| 108 |
|
| 109 |
start_test "Checking for out-of-order Content header handling in draft" |
| 110 |
|
| 111 |
cat > "`mhpath new`" <<'EOF' |
| 112 |
From: Somebody <[email protected]> |
| 113 |
To: Nobody <[email protected]> |
| 114 |
Subject: Test message |
| 115 |
Content-Fart: nothing |
| 116 |
MIME-Version: 1.0 |
| 117 |
-------- |
| 118 |
This is a test |
| 119 |
EOF |
| 120 |
|
| 121 |
cat >"$expected" <<'EOF' |
| 122 |
From: Somebody <[email protected]> |
| 123 |
To: Nobody <[email protected]> |
| 124 |
Subject: Test message |
| 125 |
Content-Fart: nothing |
| 126 |
MIME-Version: 1.0 |
| 127 |
-------- |
| 128 |
This is a test |
| 129 |
EOF |
| 130 |
|
| 131 |
run_test "mhbuild `mhpath last`" "mhbuild: draft shouldn't contain MIME-Version: field" |
| 132 |
check "`mhpath last`" "$expected" 'keep first' |
| 133 |
|
| 134 |
cat >"$expected" <<'EOF' |
| 135 |
From: Somebody <[email protected]> |
| 136 |
To: Nobody <[email protected]> |
| 137 |
Subject: Test message |
| 138 |
Content-Fart: nothing |
| 139 |
MIME-Version: 1.0 |
| 140 |
-------- |
| 141 |
This is a test |
| 142 |
EOF |
| 143 |
|
| 144 |
run_test "mhbuild -auto `mhpath last`" |
| 145 |
check "`mhpath last`" "$expected" |
| 146 |
|
| 147 |
start_test 'Checking parsing of explicit content-type' |
| 148 |
|
| 149 |
f="`mhpath new`" |
| 150 |
cat >"$f" <<\E |
| 151 |
Subject: Test message. |
| 152 |
|
| 153 |
#<text/troff |
| 154 |
.sp |4i |
| 155 |
.ce |
| 156 |
Render \fBme\fP! |
| 157 |
E |
| 158 |
|
| 159 |
cat >"$expected" <<\E |
| 160 |
Subject: Test message. |
| 161 |
MIME-Version: 1.0 |
| 162 |
Content-Type: text/troff; charset="us-ascii" |
| 163 |
|
| 164 |
.sp |4i |
| 165 |
.ce |
| 166 |
Render \fBme\fP! |
| 167 |
E |
| 168 |
|
| 169 |
run_test "mhbuild $f" |
| 170 |
|
| 171 |
check "$f" "$expected" |
| 172 |
|
| 173 |
start_test "Checking parsing of missing content-type's type" |
| 174 |
|
| 175 |
f="`mhpath new`" |
| 176 |
cat >"$f" <<\E |
| 177 |
Subject: Test message. |
| 178 |
|
| 179 |
#< |
| 180 |
Fail. |
| 181 |
E |
| 182 |
|
| 183 |
cat >"$expected" <"$f" # Unaltered. |
| 184 |
|
| 185 |
run_test "mhbuild $f" \ |
| 186 |
"mhbuild: invalid Content-Type: field in message $f (empty type)" |
| 187 |
|
| 188 |
check "$f" "$expected" |
| 189 |
|
| 190 |
start_test "Checking parsing of missing content-type's slash" |
| 191 |
|
| 192 |
f="`mhpath new`" |
| 193 |
cat >"$f" <<\E |
| 194 |
Subject: Test message. |
| 195 |
|
| 196 |
#<foo |
| 197 |
Fail. |
| 198 |
E |
| 199 |
|
| 200 |
cat >"$expected" <"$f" # Unaltered. |
| 201 |
|
| 202 |
run_test "mhbuild $f" \ |
| 203 |
"mhbuild: invalid content-type in message $f (missing slash after \"foo\")" |
| 204 |
|
| 205 |
check "$f" "$expected" |
| 206 |
|
| 207 |
start_test "Checking parsing of missing content-type's subtype" |
| 208 |
|
| 209 |
f="`mhpath new`" |
| 210 |
cat >"$f" <<\E |
| 211 |
Subject: Test message. |
| 212 |
|
| 213 |
#<foo/ |
| 214 |
Fail. |
| 215 |
E |
| 216 |
|
| 217 |
cat >"$expected" <"$f" # Unaltered. |
| 218 |
|
| 219 |
run_test "mhbuild $f" \ |
| 220 |
"mhbuild: invalid Content-Type: field in message $f (empty subtype for \"foo\")" |
| 221 |
|
| 222 |
check "$f" "$expected" |
| 223 |
|
| 224 |
finish_test |
| 225 |
exit $failed |