Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / b6 / e6b5cf9e0f7fecf15ea770f2dfb6254b915fa8
1 Return-Path: <tomi.ollila@iki.fi>\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 29C48431FBF\r
6         for <notmuch@notmuchmail.org>; Sat, 23 Nov 2013 01:56:14 -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 pVOVIKP2+Gke for <notmuch@notmuchmail.org>;\r
16         Sat, 23 Nov 2013 01:56:06 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id D707D431FAE\r
19         for <notmuch@notmuchmail.org>; Sat, 23 Nov 2013 01:56:05 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id A823C100030;\r
22         Sat, 23 Nov 2013 11:55:59 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: david@tethera.net, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH] test: replace $PWD with YYY in emacs & emacs-show tests\r
26 In-Reply-To: <1385166355-12924-1-git-send-email-david@tethera.net>\r
27 References: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\r
28         <1385166355-12924-1-git-send-email-david@tethera.net>\r
29 User-Agent: Notmuch/0.16+175~g19e97d6 (http://notmuchmail.org) Emacs/24.3.1\r
30         (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Sat, 23 Nov 2013 11:55:59 +0200\r
35 Message-ID: <m2vbzjqw5s.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sat, 23 Nov 2013 09:56:14 -0000\r
51 \r
52 On Sat, Nov 23 2013, david@tethera.net wrote:\r
53 \r
54 > From: David Bremner <david@tethera.net>\r
55 >\r
56 > When executed command line is written to *Notmuch errors* buffer,\r
57 > shell-quote-argument will backslash-escape any char that is not in\r
58 > "POSIX filename characters" (i.e. matching "[^-0-9a-zA-Z_./\n]").\r
59 >\r
60 > Currently in two emacs tests shell has expanded $PWD as part of\r
61 > emacs variable, which will later be fed to #'shell-quote-argument\r
62 > and finally written to ERROR file. If $PWD contained non-POSIX\r
63 > filename characters, data in ERROR file will not match $PWD when\r
64 > later comparing in shell. Therefore, in these two particular cases\r
65 > the escaped $PWD is replaced with YYY in ERROR file and expected\r
66 > content is adjusted accordingly.\r
67 > ---\r
68 >\r
69 > The commit message is shamelessly boosted from Tomi's patch.  To be\r
70 > honest I didn't notice that Tomi had already sent a patch when I\r
71 > started on this, and then I was too stubborn to stop. I'm not sure\r
72 > which is better. It depends whether you think the cosmetic stuff is an\r
73 > improvement, or just gratuitous. For what it's worth (not that much as\r
74 > Tomi points out) this should work ok with spaces in the path. Better\r
75 > to light a candle than to curse the darkness, etc...\r
76 \r
77 yesyes ;D\r
78 \r
79 This patch has 2 (additional) improvements: \r
80 \r
81 1) it removes the unportable sed -i (GNU feature) \r
82 2) informs developer from which files the comparison contents are coming from\r
83 \r
84 There is also one problem: the notmuch_emacs_error_sanitize() expects\r
85 that the notmuch-command in question is always .../notmuch_fail. This \r
86 doesn't look good in a (generic) function.\r
87 \r
88 One option would be to change the regexp in notmuch_emacs_error_sanitize()\r
89 to something like:\r
90 >   -e 's|^\(command: \)[^ ]*/|\1YYY/|'\r
91 \r
92 i.e. just touch the ^command: line, remove all nonspace(*) chars until last\r
93 slash (/) before space.\r
94 \r
95 (*) we're back with this 'space' thing, but I dont's see any alternative.\r
96 Using set of allowed chars is impossible as users may have e.g. utf-8\r
97 chars in their paths... \r
98 \r
99 \r
100 >\r
101 >  test/emacs       | 15 ++++++++-------\r
102 >  test/emacs-show  | 10 +++++-----\r
103 >  test/test-lib.sh |  9 +++++++++\r
104 >  3 files changed, 22 insertions(+), 12 deletions(-)\r
105 >\r
106 > diff --git a/test/emacs b/test/emacs\r
107 > index 3b3b14d..dd544f5e 100755\r
108 > --- a/test/emacs\r
109 > +++ b/test/emacs\r
110 > @@ -881,15 +881,16 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
111 >              (with-current-buffer \"*Notmuch errors*\"\r
112 >                 (test-output \"ERROR\"))\r
113 >              (test-output))"\r
114 > -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
115 > -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
116 > +\r
117 > +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
118 > +=== OUTPUT ===\r
119 >  End of search results.\r
120 > ----\r
121 > -$PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
122 > ----\r
123 > +=== MESSAGES ===\r
124 > +YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
125 > +=== ERROR ===\r
126 >  [XXX]\r
127 > -$PWD/notmuch_fail exited with status 1\r
128 > -command: $PWD/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
129 > +YYY/notmuch_fail exited with status 1\r
130 > +command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
131 >  exit status: 1"\r
132 >  \r
133 >  test_begin_subtest "Search handles subprocess warnings"\r
134 > diff --git a/test/emacs-show b/test/emacs-show\r
135 > index fb23db4..21f1c68 100755\r
136 > --- a/test/emacs-show\r
137 > +++ b/test/emacs-show\r
138 > @@ -181,14 +181,14 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
139 >              (with-current-buffer \"*Notmuch errors*\"\r
140 >                 (test-output \"ERROR\"))\r
141 >              (test-output))"\r
142 > -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
143 > -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
144 > ----\r
145 > +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
146 > +=== OUTPUT ===\r
147 > +=== MESSAGES ===\r
148 >  This is an error (see *Notmuch errors* for more details)\r
149 > ----\r
150 > +=== ERROR ===\r
151 >  [XXX]\r
152 >  This is an error\r
153 > -command: $PWD/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
154 > +command: YYY/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
155 >  exit status: 1\r
156 >  stderr:\r
157 >  This is an error\r
158 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
159 > index 2aa4dfc..611aee3 100644\r
160 > --- a/test/test-lib.sh\r
161 > +++ b/test/test-lib.sh\r
162 > @@ -628,6 +628,15 @@ notmuch_json_show_sanitize ()\r
163 >       -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g'\r
164 >  }\r
165 >  \r
166 > +notmuch_emacs_error_sanitize ()\r
167 > +{\r
168 > +    for file in "$@"; do\r
169 > +     echo "=== $file ==="\r
170 > +     cat "$file"\r
171 > +    done | sed  \\r
172 > +     -e 's/^\[.*\]$/[XXX]/' \\r
173 > +     -e 's|^\(command: \)\{0,1\}/.*/notmuch_fail|\1YYY/notmuch_fail|'\r
174 > +}\r
175 >  # End of notmuch helper functions\r
176 >  \r
177 >  # Use test_set_prereq to tell that a particular prerequisite is available.\r
178 > -- \r
179 > 1.8.4.2\r
180 >\r
181 > _______________________________________________\r
182 > notmuch mailing list\r
183 > notmuch@notmuchmail.org\r
184 > http://notmuchmail.org/mailman/listinfo/notmuch\r