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