Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / bd / ec26214d332be18a8f418d1c5d891c5b7fcbc8
1 Return-Path: <bremner@tethera.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 0587F431FC4\r
6         for <notmuch@notmuchmail.org>; Fri, 22 Nov 2013 16:26: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 pvWZhhqz9lQq for <notmuch@notmuchmail.org>;\r
16         Fri, 22 Nov 2013 16:26:06 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id A5C00431FAE\r
21         for <notmuch@notmuchmail.org>; Fri, 22 Nov 2013 16:26:06 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <bremner@tethera.net>)\r
24         id 1Vk12w-0005Ql-G2; Fri, 22 Nov 2013 20:26:02 -0400\r
25 Received: (nullmailer pid 13103 invoked by uid 1000); Sat, 23 Nov 2013\r
26         00:25:58 -0000\r
27 From: david@tethera.net\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [PATCH] test: replace $PWD with YYY in emacs & emacs-show tests\r
30 Date: Fri, 22 Nov 2013 20:25:55 -0400\r
31 Message-Id: <1385166355-12924-1-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 1.8.4.2\r
33 In-Reply-To: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\r
34 References: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.13\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Sat, 23 Nov 2013 00:26:14 -0000\r
48 \r
49 From: David Bremner <david@tethera.net>\r
50 \r
51 When executed command line is written to *Notmuch errors* buffer,\r
52 shell-quote-argument will backslash-escape any char that is not in\r
53 "POSIX filename characters" (i.e. matching "[^-0-9a-zA-Z_./\n]").\r
54 \r
55 Currently in two emacs tests shell has expanded $PWD as part of\r
56 emacs variable, which will later be fed to #'shell-quote-argument\r
57 and finally written to ERROR file. If $PWD contained non-POSIX\r
58 filename characters, data in ERROR file will not match $PWD when\r
59 later comparing in shell. Therefore, in these two particular cases\r
60 the escaped $PWD is replaced with YYY in ERROR file and expected\r
61 content is adjusted accordingly.\r
62 ---\r
63 \r
64 The commit message is shamelessly boosted from Tomi's patch.  To be\r
65 honest I didn't notice that Tomi had already sent a patch when I\r
66 started on this, and then I was too stubborn to stop. I'm not sure\r
67 which is better. It depends whether you think the cosmetic stuff is an\r
68 improvement, or just gratuitous. For what it's worth (not that much as\r
69 Tomi points out) this should work ok with spaces in the path. Better\r
70 to light a candle than to curse the darkness, etc...\r
71 \r
72  test/emacs       | 15 ++++++++-------\r
73  test/emacs-show  | 10 +++++-----\r
74  test/test-lib.sh |  9 +++++++++\r
75  3 files changed, 22 insertions(+), 12 deletions(-)\r
76 \r
77 diff --git a/test/emacs b/test/emacs\r
78 index 3b3b14d..dd544f5e 100755\r
79 --- a/test/emacs\r
80 +++ b/test/emacs\r
81 @@ -881,15 +881,16 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
82                (with-current-buffer \"*Notmuch errors*\"\r
83                   (test-output \"ERROR\"))\r
84                (test-output))"\r
85 -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
86 -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
87 +\r
88 +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
89 +=== OUTPUT ===\r
90  End of search results.\r
91 ----\r
92 -$PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
93 ----\r
94 +=== MESSAGES ===\r
95 +YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
96 +=== ERROR ===\r
97  [XXX]\r
98 -$PWD/notmuch_fail exited with status 1\r
99 -command: $PWD/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
100 +YYY/notmuch_fail exited with status 1\r
101 +command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
102  exit status: 1"\r
103  \r
104  test_begin_subtest "Search handles subprocess warnings"\r
105 diff --git a/test/emacs-show b/test/emacs-show\r
106 index fb23db4..21f1c68 100755\r
107 --- a/test/emacs-show\r
108 +++ b/test/emacs-show\r
109 @@ -181,14 +181,14 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
110                (with-current-buffer \"*Notmuch errors*\"\r
111                   (test-output \"ERROR\"))\r
112                (test-output))"\r
113 -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
114 -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
115 ----\r
116 +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
117 +=== OUTPUT ===\r
118 +=== MESSAGES ===\r
119  This is an error (see *Notmuch errors* for more details)\r
120 ----\r
121 +=== ERROR ===\r
122  [XXX]\r
123  This is an error\r
124 -command: $PWD/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
125 +command: YYY/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
126  exit status: 1\r
127  stderr:\r
128  This is an error\r
129 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
130 index 2aa4dfc..611aee3 100644\r
131 --- a/test/test-lib.sh\r
132 +++ b/test/test-lib.sh\r
133 @@ -628,6 +628,15 @@ notmuch_json_show_sanitize ()\r
134         -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g'\r
135  }\r
136  \r
137 +notmuch_emacs_error_sanitize ()\r
138 +{\r
139 +    for file in "$@"; do\r
140 +       echo "=== $file ==="\r
141 +       cat "$file"\r
142 +    done | sed  \\r
143 +       -e 's/^\[.*\]$/[XXX]/' \\r
144 +       -e 's|^\(command: \)\{0,1\}/.*/notmuch_fail|\1YYY/notmuch_fail|'\r
145 +}\r
146  # End of notmuch helper functions\r
147  \r
148  # Use test_set_prereq to tell that a particular prerequisite is available.\r
149 -- \r
150 1.8.4.2\r
151 \r