Re: [PATCH 2/4] test: sanitize Date and timestamp fields in json
[notmuch-archives.git] / 74 / 6b86750281b5f7685640d4b1f4aa87c5a0e5ef
1 Return-Path: <schnouki@schnouki.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 0FBB4429E44\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 01:46:33 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.1\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id tSjsAp1sj1gc for <notmuch@notmuchmail.org>;\r
17         Wed,  7 Dec 2011 01:46:32 -0800 (PST)\r
18 Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
19         by olra.theworths.org (Postfix) with ESMTP id 35D26431FD0\r
20         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 01:46:32 -0800 (PST)\r
21 Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])\r
22         by ks3536.kimsufi.com (Postfix) with ESMTPSA id E98856A0026;\r
23         Wed,  7 Dec 2011 10:46:29 +0100 (CET)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
25         s=key-schnouki; t=1323251190;\r
26         bh=lB3SyTPEfYd4szFwQvtNj0zwCEtQvtKfXjDIw2vzff8=;\r
27         h=From:To:Subject:Date:Message-Id;\r
28         b=kcPf/W/ue7bu1ZdooydfCEe7oSRKzRDFrlOEGMtaYqxTnzg0FW9T9Lwh4TncXJoHx\r
29         zLjJgJDV9HXZn3PYxdckpGRSgjyXKOqVuAifZ6PSEYrExQVkGq6+gAMVc3UujumOok\r
30         X5DCked6UhR6Uhyg/0AdRXOHQudpPEar8HSjvQWg=\r
31 From: Thomas Jost <schnouki@schnouki.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 1/2] test: add a function to run Python tests\r
34 Date: Wed,  7 Dec 2011 10:46:17 +0100\r
35 Message-Id: <1323251178-20409-1-git-send-email-schnouki@schnouki.net>\r
36 X-Mailer: git-send-email 1.7.8\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Wed, 07 Dec 2011 09:46:33 -0000\r
50 \r
51 The new test_python() function makes writing Python tests a little easier:\r
52 - it sets the environment variables as needed\r
53 - it redirects stdout to the OUTPUT file (like test_emacs()).\r
54 \r
55 This commit also declares python as an external prereq.\r
56 \r
57 The stdout redirection is required to avoid trouble when running commands like\r
58 "python 'script' | sort > OUTPUT": in such a case, any error due to a missing\r
59 external prereq would be "swallowed" by sort, resulting to a failed test instead\r
60 of a skipped one.\r
61 ---\r
62  test/python      |    6 ++----\r
63  test/test-lib.sh |    9 +++++++++\r
64  2 files changed, 11 insertions(+), 4 deletions(-)\r
65 \r
66 diff --git a/test/python b/test/python\r
67 index f737749..c3aa726 100755\r
68 --- a/test/python\r
69 +++ b/test/python\r
70 @@ -5,9 +5,7 @@ test_description="python bindings"\r
71  add_email_corpus\r
72  \r
73  test_begin_subtest "compare thread ids"\r
74 -LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib \\r
75 -PYTHONPATH=$TEST_DIRECTORY/../bindings/python \\r
76 -python <<EOF | sort > OUTPUT\r
77 +test_python <<EOF\r
78  import notmuch\r
79  db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)\r
80  q_new = notmuch.Query(db, 'tag:inbox')\r
81 @@ -15,5 +13,5 @@ for t in q_new.search_threads():\r
82      print t.get_thread_id()\r
83  EOF\r
84  notmuch search --output=threads tag:inbox | sed s/^thread:// | sort > EXPECTED\r
85 -test_expect_equal_file OUTPUT EXPECTED\r
86 +test_expect_equal_file <(sort OUTPUT) EXPECTED\r
87  test_done\r
88 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
89 index a975957..519bd84 100644\r
90 --- a/test/test-lib.sh\r
91 +++ b/test/test-lib.sh\r
92 @@ -919,6 +919,14 @@ test_emacs () {\r
93         emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
94  }\r
95  \r
96 +test_python() {\r
97 +       export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib\r
98 +       export PYTHONPATH=$TEST_DIRECTORY/../bindings/python\r
99 +\r
100 +       (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \\r
101 +               | python -\r
102 +}\r
103 +\r
104  test_reset_state_ () {\r
105         test -z "$test_init_done_" && test_init_\r
106  \r
107 @@ -1148,3 +1156,4 @@ test_declare_external_prereq emacs\r
108  test_declare_external_prereq emacsclient\r
109  test_declare_external_prereq gdb\r
110  test_declare_external_prereq gpg\r
111 +test_declare_external_prereq python\r
112 -- \r
113 1.7.8\r
114 \r