--- /dev/null
+Return-Path: <bremner@tethera.net>\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 0587F431FC4\r
+ for <notmuch@notmuchmail.org>; Fri, 22 Nov 2013 16:26: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 pvWZhhqz9lQq for <notmuch@notmuchmail.org>;\r
+ Fri, 22 Nov 2013 16:26:06 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A5C00431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 22 Nov 2013 16:26:06 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1Vk12w-0005Ql-G2; Fri, 22 Nov 2013 20:26:02 -0400\r
+Received: (nullmailer pid 13103 invoked by uid 1000); Sat, 23 Nov 2013\r
+ 00:25:58 -0000\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: replace $PWD with YYY in emacs & emacs-show tests\r
+Date: Fri, 22 Nov 2013 20:25:55 -0400\r
+Message-Id: <1385166355-12924-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.4.2\r
+In-Reply-To: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <1385154389-3243-1-git-send-email-tomi.ollila@iki.fi>\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 00:26:14 -0000\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
+ 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