--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 DDDEB431FAF\r
+ for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 19:25:08 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 HRDJVlyT4alS for <notmuch@notmuchmail.org>;\r
+ Tue, 27 Nov 2012 19:25:07 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
+ [18.7.68.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 19F6F431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 19:25:07 -0800 (PST)\r
+X-AuditID: 12074422-b7f196d00000398d-d5-50b58411e2d9\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 21.44.14733.11485B05; Tue, 27 Nov 2012 22:25:05 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAS3P2m0015106; \r
+ Tue, 27 Nov 2012 22:25:02 -0500\r
+Received: from drake.dyndns.org\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAS3P08F001546\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 27 Nov 2012 22:25:02 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TdYGi-0003ny-OY; Tue, 27 Nov 2012 22:25:00 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: Make the emacsclient binary user-configurable\r
+Date: Tue, 27 Nov 2012 22:24:59 -0500\r
+Message-Id: <1354073099-14582-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsUixG6noivYsjXA4P1nC4vrN2cyOzB6PFt1\r
+ izmAMYrLJiU1J7MstUjfLoEr4/nd54wFHxQq/v/+y9jAuEi6i5GTQ0LARKLrwmFWCFtM4sK9\r
+ 9WxdjFwcQgL7GCX2XF/CDOFsYJSY0t7JCuE8YpLY+e8ZO4Qzl1Hi6IwPzCD9bAIaEtv2L2cE\r
+ sUUEpCV23p0N1MHBwSygJvGnSwUkLCzgIjH14h0mEJtFQFXixOU+MJtXwEHizsVNTBBnKEp0\r
+ P5vANoGRdwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdU73czBK91JTSTYzgMHBR2sH486DS\r
+ IUYBDkYlHl4Lq60BQqyJZcWVuYcYJTmYlER5X9QDhfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nw\r
+ pkUC5XhTEiurUovyYVLSHCxK4rzXUm76CwmkJ5akZqemFqQWwWRlODiUJHjtmoEaBYtS01Mr\r
+ 0jJzShDSTBycIMN5gIbfawIZXlyQmFucmQ6RP8Woy9H7r+sJoxBLXn5eqpQ4ryDIIAGQoozS\r
+ PLg5sPh9xSgO9JYw70OQUTzA2Ieb9ApoCRPQkuTrG0GWlCQipKQaGOdcYHmQ9Vva7sKlXre2\r
+ GUEha8WjFzp++PfrqfTxJBE9jzU/vqnsP9GZE7F3p/nSKAHf7OniM3ytN27WeNi8Wsw97NzG\r
+ hf+bZAw3M33xD7wRnfx90bz7EoHGPte5t8ty1lnGxW/rbtYumfTj562PFtxWrvFliquktO/z\r
+ Zr2eb30uetOTgusiN5VYijMSDbWYi4oTAah+6NG6AgAA\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: Wed, 28 Nov 2012 03:25:09 -0000\r
+\r
+And require that if TEST_EMACS is specified, so is TEST_EMACSCLIENT.\r
+\r
+Previously, the test framework always used "emacsclient", even if the\r
+Emacs in use was overridden by TEST_EMACS. This causes problems if\r
+both Emacs 23 and Emacs 24 are installed, the Emacs 23 emacsclient is\r
+the system default, but TEST_EMACS is set to emacs24. Specifically,\r
+with an Emacs 24 server and an Emacs 23 client, emacs tests that run\r
+very quickly may produce no output from emacsclient, causing the test\r
+to fail.\r
+\r
+The Emacs server uses a very simple line-oriented protocol in which\r
+the client sends a request to evaluate an expression and the server\r
+sends a request to print the result of evaluation. Prior to Emacs bzr\r
+commit 107565 on March 11th, 2012 (released in Emacs 24.1), if\r
+multiple commands were sent to the emacsclient between when it sent\r
+the evaluation command and when it entered its receive loop, it would\r
+only process the first response command, ignoring the rest of the\r
+received buffer. This wasn't a problem with the Emacs 23 server\r
+because it sent only the command to print the evaluation result.\r
+However, the Emacs 24 server first sends an unprompted command\r
+specifying the PID of the Emacs server, then processes the evaluation\r
+request, then sends the command to print the result. If the\r
+evaluation is fast enough, it can send both of these commands before\r
+emacsclient enters the receive loop. Hence, if an Emacs 24 server is\r
+used with an Emacs 23 emacsclient, it may miss the response printing\r
+command, ultimately causing intermittent notmuch test failures.\r
+---\r
+ test/README | 10 +++++-----\r
+ test/test-lib.sh | 12 +++++++++---\r
+ 2 files changed, 14 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/test/README b/test/README\r
+index 6dc3034..81c232d 100644\r
+--- a/test/README\r
++++ b/test/README\r
+@@ -69,12 +69,12 @@ can be specified as follows:\r
+ \r
+ make test OPTIONS="--verbose"\r
+ \r
+-You can choose an emacs binary to run the tests in one of the\r
+-following ways.\r
++You can choose an emacs binary (and corresponding emacsclient) to run\r
++the tests in one of the following ways.\r
+ \r
+- TEST_EMACS=my-special-emacs make test\r
+- TEST_EMACS=my-special-emacs ./emacs\r
+- make test TEST_EMACS=my-special-emacs\r
++ TEST_EMACS=my-special-emacs TEST_EMACSCLIENT=my-emacsclient make test\r
++ TEST_EMACS=my-special-emacs TEST_EMACSCLIENT=my-emacsclient ./emacs\r
++ make test TEST_EMACS=my-special-emacs TEST_EMACSCLIENT=my-emacsclient\r
+ \r
+ Skipping Tests\r
+ --------------\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 467b83c..e092231 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -49,7 +49,13 @@ TZ=UTC\r
+ TERM=dumb\r
+ export LANG LC_ALL PAGER TERM TZ\r
+ GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\r
++if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \\r
++ ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then\r
++ echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2\r
++ exit 1\r
++fi\r
+ TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}\r
++TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}\r
+ \r
+ # Protect ourselves from common misconfiguration to export\r
+ # CDPATH into the environment\r
+@@ -969,7 +975,7 @@ test_emacs () {\r
+ missing_dependencies=\r
+ test_require_external_prereq dtach || missing_dependencies=1\r
+ test_require_external_prereq emacs || missing_dependencies=1\r
+- test_require_external_prereq emacsclient || missing_dependencies=1\r
++ test_require_external_prereq ${TEST_EMACSCLIENT} || missing_dependencies=1\r
+ test -z "$missing_dependencies" || return\r
+ \r
+ if [ -z "$EMACS_SERVER" ]; then\r
+@@ -1005,7 +1011,7 @@ test_emacs () {\r
+ rm -f OUTPUT\r
+ touch OUTPUT\r
+ \r
+- emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
++ ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
+ }\r
+ \r
+ test_python() {\r
+@@ -1158,7 +1164,7 @@ rm -f y\r
+ # declare prerequisites for external binaries used in tests\r
+ test_declare_external_prereq dtach\r
+ test_declare_external_prereq emacs\r
+-test_declare_external_prereq emacsclient\r
++test_declare_external_prereq ${TEST_EMACSCLIENT}\r
+ test_declare_external_prereq gdb\r
+ test_declare_external_prereq gpg\r
+ test_declare_external_prereq python\r
+-- \r
+1.7.10.4\r
+\r