From 49f443410bc88ab0e9adb796295cbfb0968ee994 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 22 Apr 2014 14:37:39 +2000 Subject: [PATCH] [PATCH 02/11] test: New tests for Emacs charset handling --- ee/ad188d254b74a0b058912bf5e9e1622d53c349 | 250 ++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 ee/ad188d254b74a0b058912bf5e9e1622d53c349 diff --git a/ee/ad188d254b74a0b058912bf5e9e1622d53c349 b/ee/ad188d254b74a0b058912bf5e9e1622d53c349 new file mode 100644 index 000000000..787eb421c --- /dev/null +++ b/ee/ad188d254b74a0b058912bf5e9e1622d53c349 @@ -0,0 +1,250 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A1CFF431FBC + for ; Mon, 21 Apr 2014 11:38:17 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id JaJJ5P7zFyMU for ; + Mon, 21 Apr 2014 11:38:13 -0700 (PDT) +Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu + [18.7.68.36]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0A314431FC4 + for ; Mon, 21 Apr 2014 11:38:00 -0700 (PDT) +X-AuditID: 12074424-f79e26d000000c70-d5-53556588b234 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 70.45.03184.88565535; Mon, 21 Apr 2014 14:38:00 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s3LIbuSc022317; + Mon, 21 Apr 2014 14:37:57 -0400 +Received: from drake.dyndns.org + (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [216.15.114.40]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3LIbsGG029710 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 21 Apr 2014 14:37:56 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1WcJ6I-0003ku-BI; Mon, 21 Apr 2014 14:37:54 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 02/11] test: New tests for Emacs charset handling +Date: Mon, 21 Apr 2014 14:37:39 -0400 +Message-Id: <1398105468-14317-3-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.9.1 +In-Reply-To: <1398105468-14317-1-git-send-email-amdragon@mit.edu> +References: <1398105468-14317-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixG6nrtuRGhps8PkFm8X1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CV8eDjOsaC49oVyztOMDYwblDpYuTkkBAwkWh4t4IdwhaTuHBv + PVsXIxeHkMBsJokfcy6yQjgbGSW+zn3PDuHcYZK496ePEcKZyyixtn0dI0g/m4CGxLb9y8Fs + EQFpiZ13ZwO1c3AwC6hJ/OkCWycs4CgxY+pzsHUsAqoSH07+YgaxeQUcJI40H2CBOENO4uSx + yawgNidQfdvql2D1QkA1G/auYZrAyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrrlebmaJ + XmpK6SZGcNi4qOxgbD6kdIhRgINRiYdXwiA0WIg1say4MvcQoyQHk5Io76sooBBfUn5KZUZi + cUZ8UWlOavEhRgkOZiUR3vWaQDnelMTKqtSifJiUNAeLkjjvW2urYCGB9MSS1OzU1ILUIpis + DAeHkgTvwhSgRsGi1PTUirTMnBKENBMHJ8hwHqDhF0FqeIsLEnOLM9Mh8qcYFaXEedtAEgIg + iYzSPLheWFy/YhQHekWYtwWkigeYEuC6XwENZgIa/GRLCMjgkkSElFQD42qpmC/Nff//zhYP + X6KVFXfvjkdRQXbtydg/Vm/uv9rmUzpT/fevrU/zQyrWWtTI3G50KVd2Xs65TMRzW3RbnEjK + pvp04xfN23oOXjHv3Kc6TeF31JO56w+dv551Zde6iniWNarTvI91VTkbme5YcvTD7TN1h6vz + FshetvJ4VnUtRbNKyvuemRJLcUaioRZzUXEiAJByPTnGAgAA +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 21 Apr 2014 18:38:17 -0000 + +The test of viewing 8bit messages is known-broken. The rest pass, but +for very fragile reasons. The next several commits will fix the +known-broken test and make our charset handling robust. +--- + test/T455-emacs-charsets.sh | 141 ++++++++++++++++++++++++++++++++++++++++++++ + test/test-lib.el | 4 +- + 2 files changed, 144 insertions(+), 1 deletion(-) + create mode 100755 test/T455-emacs-charsets.sh + +diff --git a/test/T455-emacs-charsets.sh b/test/T455-emacs-charsets.sh +new file mode 100755 +index 0000000..a42a1d2 +--- /dev/null ++++ b/test/T455-emacs-charsets.sh +@@ -0,0 +1,141 @@ ++#!/usr/bin/env bash ++ ++test_description="emacs notmuch-show charset handling" ++. ./test-lib.sh ++ ++ ++UTF8_YEN=$'\xef\xbf\xa5' ++BIG5_YEN=$'\xa2\x44' ++ ++# 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]="Yen: =A2=44"' ++ ++# 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 <EXPECTED ++Yen: $UTF8_YEN ++EOF ++test_expect_equal_file OUTPUT EXPECTED ++ ++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 <EXPECTED ++Yen: $UTF8_YEN ++EOF ++test_expect_equal_file OUTPUT EXPECTED ++ ++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 <EXPECTED ++[ text/html ] ++Yen: $UTF8_YEN ++EOF ++test_expect_equal_file OUTPUT EXPECTED ++ ++# 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 <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 <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 <EXPECTED ++Yen: $BIG5_YEN ++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 <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 <EXPECTED ++Yen: =A2=44 ++EOF ++test_expect_equal_file OUTPUT EXPECTED ++ ++test_begin_subtest "8bit text message are not decoded when viewing" ++test_subtest_known_broken ++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 <EXPECTED ++Yen: $BIG5_YEN ++EOF ++test_expect_equal_file OUTPUT EXPECTED ++ ++test_done +diff --git a/test/test-lib.el b/test/test-lib.el +index 437f83f..dd3446e 100644 +--- a/test/test-lib.el ++++ b/test/test-lib.el +@@ -57,7 +57,9 @@ (defun test-output (&optional filename) + (defun test-visible-output (&optional filename) + "Save visible text in current buffer to file FILENAME. Default + FILENAME is OUTPUT." +- (let ((text (visible-buffer-string))) ++ (let ((text (visible-buffer-string)) ++ ;; Tests expect output in UTF-8 encoding ++ (coding-system-for-write 'utf-8)) + (with-temp-file (or filename "OUTPUT") (insert text)))) + + (defun visible-buffer-string () +-- +1.9.1 + -- 2.26.2