From bb5497dabc937695300836c8a60e825e8e8dd35e Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 24 Apr 2014 15:38:57 +0100 Subject: [PATCH] Re: [PATCH 02/11] test: New tests for Emacs charset handling --- fd/ebdea1bfb3db2b7ddd3168a73ba45af77d26fe | 274 ++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 fd/ebdea1bfb3db2b7ddd3168a73ba45af77d26fe diff --git a/fd/ebdea1bfb3db2b7ddd3168a73ba45af77d26fe b/fd/ebdea1bfb3db2b7ddd3168a73ba45af77d26fe new file mode 100644 index 000000000..15afc810f --- /dev/null +++ b/fd/ebdea1bfb3db2b7ddd3168a73ba45af77d26fe @@ -0,0 +1,274 @@ +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 02C3A431FAF + for ; Thu, 24 Apr 2014 07:39:12 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.502 +X-Spam-Level: +X-Spam-Status: No, score=0.502 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, 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 0w2N8wlcK4Xi for ; + Thu, 24 Apr 2014 07:39:06 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 5E5B1431FAE + for ; Thu, 24 Apr 2014 07:39:06 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1WdKnj-0005aX-Fu; Thu, 24 Apr 2014 15:39:02 +0100 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1WdKni-00061H-St; Thu, 24 Apr 2014 15:38:59 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 02/11] test: New tests for Emacs charset handling +In-Reply-To: <1398105468-14317-3-git-send-email-amdragon@mit.edu> +References: <1398105468-14317-1-git-send-email-amdragon@mit.edu> + <1398105468-14317-3-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Thu, 24 Apr 2014 15:38:57 +0100 +Message-ID: <87mwfau70e.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 49fbe5710ce73b4679e68641e94890fd (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Thu, 24 Apr 2014 14:39:12 -0000 + + +On Mon, 21 Apr 2014, Austin Clements wrote: +> 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. + +Hi + +On one of my systems one of these (non-broken) tests fails. I am not +sure whether I messed up my emacs/environment when doing stuff remotely +recently so it could just be my system + + +> --- +> 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 + +It's this test: I get an extra newline after the UFT8_YEN. + +This is with emacs 23.4.1 on a Debian wheezy(ish) system. + +But as said it could be my fault: I think some odd things happened when +I tried to install emacs 24 and 23 simultaneously to help testing +things. + +Best wishes + +Mark + + +> + +> +# 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2