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 8CE894196F2 for ; Tue, 13 Apr 2010 09:37:58 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.8 X-Spam-Level: X-Spam-Status: No, score=0.8 tagged_above=-999 required=5 tests=[BAYES_50=0.8] autolearn=unavailable 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 w5bepLb46qVi for ; Tue, 13 Apr 2010 09:37:58 -0700 (PDT) Received: from sam.mediasupervision.de (sam.mediasupervision.de [80.152.3.104]) by olra.theworths.org (Postfix) with ESMTP id 25FF6431FC1 for ; Tue, 13 Apr 2010 09:37:58 -0700 (PDT) Received: from localhost (sam.mediasupervision.de [127.0.0.1]) by sam.mediasupervision.de (Postfix) with ESMTP id 82F35485C67 for ; Tue, 13 Apr 2010 18:37:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at sam.mediasupervision.de Received: from sam.mediasupervision.de ([127.0.0.1]) by localhost (sam.mediasupervision.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nicTAqAV5sf1 for ; Tue, 13 Apr 2010 18:37:57 +0200 (CEST) Received: by sam.mediasupervision.de (Postfix, from userid 1000) id 60C54485DE6; Tue, 13 Apr 2010 18:37:57 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Subject: [PATCH] First tests for JSON output and UTF-8 in mail body and subject From: Gregor Hoffleit To: notmuch In-reply-to: <87r5mje55l.fsf@yoom.home.cworth.org> References: <1267697893-sup-4538@sam.mediasupervision.de> <87r5mje55l.fsf@yoom.home.cworth.org> Date: Tue, 13 Apr 2010 18:37:57 +0200 Message-Id: <1271176622-sup-4680@sam.mediasupervision.de> User-Agent: Sup/git Content-Transfer-Encoding: 8bit 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: Tue, 13 Apr 2010 16:37:58 -0000 The test suite doesn't yet cover --format=json output nor UTF-8 in subject or body. This patch starts with test cases for 'search --format=json' and 'show --format=json'. Furthermore, it has test cases for a search for a UTF-8 string in a mail body for a UTF-8 string in a mail subject. Finally, it has a test case for --format=json with UTF-8 messages, demonstrating the fix in 1267697893-sup-4538@sam.mediasupervision.de. --- test/notmuch-test | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/test/notmuch-test b/test/notmuch-test index 1c5191b..b2a0756 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -146,7 +146,7 @@ add_message () } NOTMUCH_IGNORED_OUTPUT_REGEXP='^Processed [0-9]*( total)? file|Found [0-9]* total file' -NOTMUCH_THREAD_ID_SQUELCH='s/thread:................/thread:XXX/' +NOTMUCH_THREAD_ID_SQUELCH='s/thread:................/thread:XXX/;s/"thread": "................",/"thread": "XXX",/' execute_expecting () { args=$1 @@ -348,6 +348,42 @@ add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:0 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"' execute_expecting "search '\"body search (phrase)\"'" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)" +printf " Show message: json...\t\t" +add_message '[subject]="json-show-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-show-message"' +execute_expecting "show --format=json 'json-show-message'" '[[[{"id": "'${gen_msg_id}'", "match": true, "filename": "'${gen_msg_filename}'", "date_unix": 946728000, "date_relative": "2000-01-01", "tags": ["inbox","unread"], "headers": {"Subject": "json-show-subject", "From": "Notmuch Test Suite ", "To": "Notmuch Test Suite ", "Cc": "", "Bcc": "", "Date": "Sat, 01 Jan 2000 12:00:00 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "json-show-message\n"}]}, []]]]' + +printf " Search message: json...\t" +add_message '[subject]="json-search-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-search-message"' +execute_expecting "search --format=json 'json-search-message'" '[{"thread": "XXX", +"timestamp": 946724400, +"matched": 1, +"total": 1, +"authors": "Notmuch Test Suite", +"subject": "json-search-subject", +"tags": ["inbox", "unread"]}]' + +printf " Search by subject (utf-8):...\t" +add_message [subject]=utf8-sübjéct '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' +execute_expecting "search subject:utf8-sübjéct" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)" + +printf " Search body (utf-8):...\t" +add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="message body utf8: bödý"' +execute_expecting "search 'bödý'" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)" + +printf " Show message: json, utf-8...\t" +add_message '[subject]="json-show-utf8-body-sübjéct"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="jsön-show-méssage"' +execute_expecting "show --format=json 'jsön-show-méssage'" '[[[{"id": "'${gen_msg_id}'", "match": true, "filename": "'${gen_msg_filename}'", "date_unix": 946728000, "date_relative": "2000-01-01", "tags": ["inbox","unread"], "headers": {"Subject": "json-show-utf8-body-sübjéct", "From": "Notmuch Test Suite ", "To": "Notmuch Test Suite ", "Cc": "", "Bcc": "", "Date": "Sat, 01 Jan 2000 12:00:00 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "jsön-show-méssage\n"}]}, []]]]' + +printf " Search message: json, utf-8...\t" +add_message '[subject]="json-search-utf8-body-sübjéct"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="jsön-search-méssage"' +execute_expecting "search --format=json 'jsön-search-méssage'" '[{"thread": "XXX", +"timestamp": 946724400, +"matched": 1, +"total": 1, +"authors": "Notmuch Test Suite", +"subject": "json-search-utf8-body-sübjéct", +"tags": ["inbox", "unread"]}]' + printf " Search by from: (address)...\t" add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com execute_expecting "search from:searchbyfrom@example.com" "thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"