add a test for mhbuild rfc2047-support
[mmh] / test / tests / mhbuild / test-header-encode
1 #!/bin/sh
2 ######################################################
3 #
4 # Test encoding headers according to RFC 2047
5 #
6 ######################################################
7
8 # TODO: Move to a common file tests can source; need more framework...
9 failed=0
10 check() {
11     diff -u $expected $actual
12     if [ $? -ne 0 ]; then
13         failed=$((failed + 1))
14     fi
15 }
16
17 # Make a draft file forwarding two messages.
18 mkdraft() {
19     cat > $draft <<EOF
20 From: Mr Foo Bar <foobar@example.com>
21 To: Somebody <somebody@example.com>
22 Subject: This is รค test
23
24 This is a test
25 EOF
26 }
27
28 # Munge the Content-Id from the draft after mhbuild, so we have a reliable
29 # value to check.
30 mungedraft() {
31     sed 's/\(Content-ID:\) <[^>][^>]*>/\1 <TESTID>/' $draft > $actual
32 }
33
34 draft=$MH_TEST_DIR/$$.draft
35 expected=$MH_TEST_DIR/$$.expected
36 actual=$MH_TEST_DIR/$$.actual
37
38 # check mhbuild
39 cat > $expected <<EOF
40 From: Mr Foo Bar <foobar@example.com>
41 To: Somebody <somebody@example.com>
42 Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
43 MIME-Version: 1.0
44 Content-Type: text/plain; charset="us-ascii"
45 Content-ID: <TESTID>
46
47 This is a test
48 EOF
49 mkdraft
50 mhbuild $draft
51 mungedraft
52 check
53
54 exit $failed