unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob dbc4c71edc7f44bcae9de1f0a56e2964498ca869 4148 bytes (raw)
name: test/T455-emacs-charsets.sh 	 # note: path name is non-authoritative(*)

  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
 
#!/usr/bin/env bash

test_description="emacs notmuch-show charset handling"
. $(dirname "$0")/test-lib.sh || exit 1
. $NOTMUCH_BUILDDIR/test/test-lib-emacs.sh || exit 1


UTF8_YEN=$'\xef\xbf\xa5'
BIG5_YEN=$'\xa2\x44'

test_require_emacs

# Add four messages with unusual encoding requirements:
#
# 1) text/plain in quoted-printable big5
generate_message \
    [id]=test-plain@example.com \
    '[content-type]="text/plain; charset=big5"' \
    '[content-transfer-encoding]=quoted-printable' \
    '[body]="Yen: =A2=44"'

# 2) text/plain in 8bit big5
generate_message \
    [id]=test-plain-8bit@example.com \
    '[content-type]="text/plain; charset=big5"' \
    '[content-transfer-encoding]=8bit' \
    '[body]="Yen: '$BIG5_YEN'"'

# 3) text/html in quoted-printable big5
generate_message \
    [id]=test-html@example.com \
    '[content-type]="text/html; charset=big5"' \
    '[content-transfer-encoding]=quoted-printable' \
    '[body]="<html><body>Yen: =A2=44</body></html>"'

# 4) application/octet-stream in quoted-printable of big5 text
generate_message \
    [id]=test-binary@example.com \
    '[content-type]="application/octet-stream"' \
    '[content-transfer-encoding]=quoted-printable' \
    '[body]="Yen: =A2=44"'

notmuch new > /dev/null

# Test rendering

test_begin_subtest "Text parts are decoded when rendering"
test_emacs '(notmuch-show "id:test-plain@example.com")
	    (test-visible-output "OUTPUT.raw")'
awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
cat <<EOF >EXPECTED
Yen: $UTF8_YEN
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "8bit text parts are decoded when rendering"
test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
	    (test-visible-output "OUTPUT.raw")'
awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
cat <<EOF >EXPECTED
Yen: $UTF8_YEN
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "HTML parts are decoded when rendering"
test_emacs '(notmuch-show "id:test-html@example.com")
	    (test-visible-output "OUTPUT.raw")'
awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
cat <<EOF >EXPECTED
[ text/html ]
Yen: $UTF8_YEN
EOF
test_expect_equal_file EXPECTED OUTPUT

# Test saving

test_begin_subtest "Text parts are not decoded when saving"
rm -f part
test_emacs '(notmuch-show "id:test-plain@example.com")
	    (search-forward "Yen")
	    (let ((standard-input "\"part\""))
	       (notmuch-show-save-part))'
cat <<EOF >EXPECTED
Yen: $BIG5_YEN
EOF
test_expect_equal_file part EXPECTED

test_begin_subtest "8bit text parts are not decoded when saving"
rm -f part
test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
	    (search-forward "Yen")
	    (let ((standard-input "\"part\""))
	       (notmuch-show-save-part))'
cat <<EOF >EXPECTED
Yen: $BIG5_YEN
EOF
test_expect_equal_file part EXPECTED

test_begin_subtest "HTML parts are not decoded when saving"
rm -f part
test_emacs '(notmuch-show "id:test-html@example.com")
	    (search-forward "Yen")
	    (let ((standard-input "\"part\""))
	       (notmuch-show-save-part))'
cat <<EOF >EXPECTED
<html><body>Yen: $BIG5_YEN</body></html>
EOF
test_expect_equal_file part EXPECTED

test_begin_subtest "Binary parts are not decoded when saving"
rm -f part
test_emacs '(notmuch-show "id:test-binary@example.com")
	    (search-forward "application/")
	    (let ((standard-input "\"part\""))
	       (notmuch-show-save-part))'
cat <<EOF >EXPECTED
Yen: $BIG5_YEN
EOF
test_expect_equal_file part EXPECTED

# Test message viewing

test_begin_subtest "Text message are not decoded when viewing"
test_emacs '(notmuch-show "id:test-plain@example.com")
	    (notmuch-show-view-raw-message)
	    (test-visible-output "OUTPUT.raw")'
awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
cat <<EOF >EXPECTED
Yen: =A2=44
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "8bit text message are not decoded when viewing"
test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
	    (notmuch-show-view-raw-message)
	    (test-visible-output "OUTPUT.raw")'
awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
cat <<EOF >EXPECTED
Yen: $BIG5_YEN
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving dbc4c71e ...
found dbc4c71e in https://yhetil.org/notmuch/20210522152741.27213-1-tomi.ollila@iki.fi/ ||
	https://yhetil.org/notmuch/20210523073443.11618-1-tomi.ollila@iki.fi/
found a0f4dc24 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 a0f4dc24e3aa607abfe1f749e0c1f881f0e238d4	test/T455-emacs-charsets.sh

applying [1/1] https://yhetil.org/notmuch/20210522152741.27213-1-tomi.ollila@iki.fi/
diff --git a/test/T455-emacs-charsets.sh b/test/T455-emacs-charsets.sh
index a0f4dc24..dbc4c71e 100755

Checking patch test/T455-emacs-charsets.sh...
Applied patch test/T455-emacs-charsets.sh cleanly.

skipping https://yhetil.org/notmuch/20210523073443.11618-1-tomi.ollila@iki.fi/ for dbc4c71e
index at:
100755 dbc4c71edc7f44bcae9de1f0a56e2964498ca869	test/T455-emacs-charsets.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).