--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 29C48431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Nov 2013 01:56:14 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id pVOVIKP2+Gke for <notmuch@notmuchmail.org>;\r
+ Sat, 23 Nov 2013 01:56:06 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id D707D431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 23 Nov 2013 01:56:05 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id A823C100030;\r
+ Sat, 23 Nov 2013 11:55:59 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: david@tethera.net, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] test: replace $PWD with YYY in emacs & emacs-show tests\r
+In-Reply-To: <1385166355-12924-1-git-send-email-david@tethera.net>\r
+References: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\r
+ <1385166355-12924-1-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.16+175~g19e97d6 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Sat, 23 Nov 2013 11:55:59 +0200\r
+Message-ID: <m2vbzjqw5s.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 23 Nov 2013 09:56:14 -0000\r
+\r
+On Sat, Nov 23 2013, david@tethera.net wrote:\r
+\r
+> From: David Bremner <david@tethera.net>\r
+>\r
+> When executed command line is written to *Notmuch errors* buffer,\r
+> shell-quote-argument will backslash-escape any char that is not in\r
+> "POSIX filename characters" (i.e. matching "[^-0-9a-zA-Z_./\n]").\r
+>\r
+> Currently in two emacs tests shell has expanded $PWD as part of\r
+> emacs variable, which will later be fed to #'shell-quote-argument\r
+> and finally written to ERROR file. If $PWD contained non-POSIX\r
+> filename characters, data in ERROR file will not match $PWD when\r
+> later comparing in shell. Therefore, in these two particular cases\r
+> the escaped $PWD is replaced with YYY in ERROR file and expected\r
+> content is adjusted accordingly.\r
+> ---\r
+>\r
+> The commit message is shamelessly boosted from Tomi's patch. To be\r
+> honest I didn't notice that Tomi had already sent a patch when I\r
+> started on this, and then I was too stubborn to stop. I'm not sure\r
+> which is better. It depends whether you think the cosmetic stuff is an\r
+> improvement, or just gratuitous. For what it's worth (not that much as\r
+> Tomi points out) this should work ok with spaces in the path. Better\r
+> to light a candle than to curse the darkness, etc...\r
+\r
+yesyes ;D\r
+\r
+This patch has 2 (additional) improvements: \r
+\r
+1) it removes the unportable sed -i (GNU feature) \r
+2) informs developer from which files the comparison contents are coming from\r
+\r
+There is also one problem: the notmuch_emacs_error_sanitize() expects\r
+that the notmuch-command in question is always .../notmuch_fail. This \r
+doesn't look good in a (generic) function.\r
+\r
+One option would be to change the regexp in notmuch_emacs_error_sanitize()\r
+to something like:\r
+> -e 's|^\(command: \)[^ ]*/|\1YYY/|'\r
+\r
+i.e. just touch the ^command: line, remove all nonspace(*) chars until last\r
+slash (/) before space.\r
+\r
+(*) we're back with this 'space' thing, but I dont's see any alternative.\r
+Using set of allowed chars is impossible as users may have e.g. utf-8\r
+chars in their paths... \r
+\r
+\r
+>\r
+> test/emacs | 15 ++++++++-------\r
+> test/emacs-show | 10 +++++-----\r
+> test/test-lib.sh | 9 +++++++++\r
+> 3 files changed, 22 insertions(+), 12 deletions(-)\r
+>\r
+> diff --git a/test/emacs b/test/emacs\r
+> index 3b3b14d..dd544f5e 100755\r
+> --- a/test/emacs\r
+> +++ b/test/emacs\r
+> @@ -881,15 +881,16 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
+> (with-current-buffer \"*Notmuch errors*\"\r
+> (test-output \"ERROR\"))\r
+> (test-output))"\r
+> -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
+> -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
+> +\r
+> +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
+> +=== OUTPUT ===\r
+> End of search results.\r
+> ----\r
+> -$PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
+> ----\r
+> +=== MESSAGES ===\r
+> +YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
+> +=== ERROR ===\r
+> [XXX]\r
+> -$PWD/notmuch_fail exited with status 1\r
+> -command: $PWD/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
+> +YYY/notmuch_fail exited with status 1\r
+> +command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox\r
+> exit status: 1"\r
+> \r
+> test_begin_subtest "Search handles subprocess warnings"\r
+> diff --git a/test/emacs-show b/test/emacs-show\r
+> index fb23db4..21f1c68 100755\r
+> --- a/test/emacs-show\r
+> +++ b/test/emacs-show\r
+> @@ -181,14 +181,14 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
+> (with-current-buffer \"*Notmuch errors*\"\r
+> (test-output \"ERROR\"))\r
+> (test-output))"\r
+> -sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
+> -test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
+> ----\r
+> +test_expect_equal "$(notmuch_emacs_error_sanitize OUTPUT MESSAGES ERROR)" "\\r
+> +=== OUTPUT ===\r
+> +=== MESSAGES ===\r
+> This is an error (see *Notmuch errors* for more details)\r
+> ----\r
+> +=== ERROR ===\r
+> [XXX]\r
+> This is an error\r
+> -command: $PWD/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
+> +command: YYY/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'\r
+> exit status: 1\r
+> stderr:\r
+> This is an error\r
+> diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+> index 2aa4dfc..611aee3 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -628,6 +628,15 @@ notmuch_json_show_sanitize ()\r
+> -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g'\r
+> }\r
+> \r
+> +notmuch_emacs_error_sanitize ()\r
+> +{\r
+> + for file in "$@"; do\r
+> + echo "=== $file ==="\r
+> + cat "$file"\r
+> + done | sed \\r
+> + -e 's/^\[.*\]$/[XXX]/' \\r
+> + -e 's|^\(command: \)\{0,1\}/.*/notmuch_fail|\1YYY/notmuch_fail|'\r
+> +}\r
+> # End of notmuch helper functions\r
+> \r
+> # Use test_set_prereq to tell that a particular prerequisite is available.\r
+> -- \r
+> 1.8.4.2\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r