[PATCH 1/9] lib: read "property" terms from messages.
[notmuch-archives.git] / 80 / 2568695b97d289563bd66c92b0ae84097813b8
1 Return-Path: <tomi.ollila@nixu.com>\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 2FDD3431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:56:05 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id R3Gt2llvTxEv for <notmuch@notmuchmail.org>;\r
16         Wed, 18 Jan 2012 06:56:03 -0800 (PST)\r
17 Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 82BFC431FAE\r
21         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:56:03 -0800 (PST)\r
22 Received: from pps.filterd (mail-gw3 [127.0.0.1])\r
23         by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id q0IEscsC016536;\r
24         Wed, 18 Jan 2012 16:56:00 +0200\r
25 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])\r
26         by mail-gw3.nixu.fi with ESMTP id 114cs19781-1\r
27         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
28         Wed, 18 Jan 2012 16:55:59 +0200\r
29 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])\r
30         by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id\r
31         q0IEtxOL004380; Wed, 18 Jan 2012 16:55:59 +0200\r
32 From: Tomi Ollila <tomi.ollila@iki.fi>\r
33 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.\r
35 In-Reply-To: <1326809224-22673-2-git-send-email-dme@dme.org>\r
36 References: <87pqei327k.fsf@gmail.com>\r
37         <1326809224-22673-1-git-send-email-dme@dme.org>\r
38         <1326809224-22673-2-git-send-email-dme@dme.org>\r
39 User-Agent: Notmuch/0.11+71~gefa5d6c (http://notmuchmail.org) Emacs/23.3.1\r
40         (i686-pc-linux-gnu)\r
41 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
42         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
43         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
44 Date: Wed, 18 Jan 2012 16:55:59 +0200\r
45 Message-ID: <yf6zkdlawlc.fsf@taco2.nixu.fi>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain; charset=us-ascii\r
48 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110,\r
49  1.0.211,       0.0.0000        definitions=2012-01-18_06:2012-01-17, 2012-01-18,\r
50         1970-01-01 signatures=0\r
51 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0\r
52         ipscore=0 suspectscore=0\r
53         phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0\r
54         reason=mlx\r
55         scancount=1 engine=6.0.2-1012030000 definitions=main-1201180111\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Wed, 18 Jan 2012 14:56:05 -0000\r
69 \r
70 On Tue, 17 Jan 2012 14:07:03 +0000, David Edmondson <dme@dme.org> wrote:\r
71 > Add a new test function to allow simpler testing of emacs\r
72 > functionality.\r
73\r
74 > `test_emacs_expect_t' takes one argument - a list expression to\r
75 > evaluate. The test passes if the expression returns `t', otherwise it\r
76 > fails and the output is reported to the tester.\r
77 > ---\r
78\r
79 > Re-worked as Dmitry suggested.\r
80\r
81 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
82 > index 7c9ce24..4b05760 100644\r
83 > --- a/test/test-lib.sh\r
84 > +++ b/test/test-lib.sh\r
85 > @@ -503,6 +503,39 @@ test_expect_equal_file ()\r
86 >      fi\r
87 >  }\r
88 >  \r
89 > +test_emacs_expect_t () {\r
90 > +     test "$#" = 1 || error "bug in the test script: not 1 parameter to test_emacs_expect_t"\r
91 > +\r
92 > +     # Run the test.\r
93 > +     if ! test_skip "$test_subtest_name"\r
94 > +     then\r
95 > +             # We cannot call 'test_emacs' in a subshell, because\r
96 > +             # the setting of EMACS_SERVER would not persist\r
97 > +             # throughout a sequence of tests, so we use a\r
98 > +             # temporary file.\r
99 > +             tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi\r
100 > +             output="$tmp/test_emacs_output.$$"\r
101 > +             test_emacs "$1" > "${output}"\r
102 > +             result=$(cat "${output}")\r
103 > +             rm -f "${output}"\r
104 > +     fi\r
105 > +\r
106 > +     # Restore state after the test.\r
107 > +     exec 1>&6 2>&7          # Restore stdout and stderr\r
108 > +     inside_subtest=\r
109 > +\r
110 > +     # Report success/failure.\r
111 > +     if ! test_skip "$test_subtest_name"\r
112 > +     then\r
113 > +             if [ "$result" == t ]\r
114 \r
115                 if [ "$result" = t ]\r
116 \r
117 to be compatible with POSIX and consistent with rest code.\r
118 \r
119 > +             then\r
120 > +                     test_ok_ "$test_subtest_name"\r
121 > +             else\r
122 > +                     test_failure_ "$test_subtest_name" "$(eval printf ${result})"\r
123 \r
124 This added 'eval' made me investigate further... running \r
125 \r
126 emacsclient --eval '(print (concat "a" "b" "\t" "c" "\n" "z"))'\r
127 \r
128 outputs "ab     c\nz" (tab between 'ab' and 'c', quotes (") around\r
129 the whole output and newlines as "\n" (even '\r' is converted)).\r
130 \r
131 If emacs tests run via test_emacs_expect_t wrote their output \r
132 to ${output} directly above code could be much cleaner in many\r
133 places. Environment variable could be used for the file name.\r
134 \r
135 Tomi\r