--- /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 11E17431FC4\r
+ for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 01:51:50 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 0fgIPzNlY3rg for <notmuch@notmuchmail.org>;\r
+ Sat, 21 Mar 2015 01:51:46 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id ADEDD431FC2\r
+ for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 01:51:46 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id EE6FE10004A;\r
+ Sat, 21 Mar 2015 10:51:21 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [Patch v4 2/9] test: add support for compiling and running C\r
+ snippets\r
+In-Reply-To: <1426352554-4383-3-git-send-email-david@tethera.net>\r
+References: <1426352554-4383-1-git-send-email-david@tethera.net>\r
+ <1426352554-4383-3-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.19+53~gb45d2f9 (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, 21 Mar 2015 10:51:21 +0200\r
+Message-ID: <m28ueq7mye.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, 21 Mar 2015 08:51:50 -0000\r
+\r
+On Sat, Mar 14 2015, David Bremner <david@tethera.net> wrote:\r
+\r
+> This is to limit the copy-pasta involved in running C tests. I decided\r
+\r
+Wat kind of spaghetti have you been eating... ;D\r
+\r
+> to keep things simple and not try to provide an actual C skeleton.\r
+>\r
+> The setting of LD_LIBRARY_PATH is to force using the built libnotmuch\r
+> rather than any potential system one.\r
+> ---\r
+> test/README | 5 +++++\r
+> test/test-lib.sh | 15 +++++++++++++++\r
+> 2 files changed, 20 insertions(+)\r
+>\r
+> diff --git a/test/README b/test/README\r
+> index 81a1c82..5b40474 100644\r
+> --- a/test/README\r
+> +++ b/test/README\r
+> @@ -84,6 +84,11 @@ the tests in one of the following ways.\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
+> +Some tests may require a c compiler. You can choose the name and flags similarly \r
+> +to with emacs, e.g.\r
+> +\r
+> + make test TEST_CC=gcc TEST_CFLAGS="-g -O2"\r
+> + \r
+> Quiet Execution\r
+> ---------------\r
+> \r
+> diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+> index 133fbe4..c7af003 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -73,6 +73,8 @@ if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \\r
+> fi\r
+> TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}\r
+> TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}\r
+> +TEST_CC=${TEST_CC:-cc}\r
+> +TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}\r
+> \r
+> # Protect ourselves from common misconfiguration to export\r
+> # CDPATH into the environment\r
+> @@ -1161,6 +1163,19 @@ test_python() {\r
+> | $cmd -\r
+> }\r
+> \r
+> +test_C() {\r
+\r
+for consistency test_C () {\r
+\r
+> + test_file="test${test_count}.c"\r
+> + exec_file=${test_file%%.c}\r
+\r
+These could be other way around, if not, exec_file=${test_file%.c} (i.e.\r
+only one % is enough).\r
+\r
+> + cat > ${test_file}\r
+> + export LD_LIBRARY_PATH=${TEST_DIRECTORY}/../lib\r
+> + ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch\r
+> + echo "== stdout ==" > OUTPUT.stdout\r
+> + echo "== stderr ==" > OUTPUT.stderr\r
+> + ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr\r
+> + cat OUTPUT.stdout OUTPUT.stderr | sed "s,$(pwd),CWD," > OUTPUT\r
+\r
+ sed "s,${PWD},CWD," OUTPUT.stdout OUTPUT.stderr > OUTPUT\r
+\r