From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [Patch v6 2/8] test: add support for compiling and running C snippets
Date: Fri, 27 Mar 2015 23:11:54 +0100 [thread overview]
Message-ID: <1427494320-1483-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1427494320-1483-1-git-send-email-david@tethera.net>
This is to limit the copy-pasta involved in running C tests. I decided
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..486d1c4 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 () {
+ exec_file="test${test_count}"
+ test_file="${exec_file}.c"
+ 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 -ltalloc
+ echo "== stdout ==" > OUTPUT.stdout
+ echo "== stderr ==" > OUTPUT.stderr
+ ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr
+ sed "s,${PWD},CWD,g" OUTPUT.stdout OUTPUT.stderr > OUTPUT
+}
+
+
# Creates a script that counts how much time it is executed and calls
# notmuch. $notmuch_counter_command is set to the path to the
# generated script. Use notmuch_counter_value() function to get the
--
2.1.4
next prev parent reply other threads:[~2015-03-27 22:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 22:11 Library logging overhaul, round 6 David Bremner
2015-03-27 22:11 ` [Patch v6 1/8] test: Add two tests for error output from notmuch_database_open David Bremner
2015-03-27 22:11 ` David Bremner [this message]
2015-03-27 22:11 ` [Patch v6 3/8] test: add error reporting tests David Bremner
2015-03-27 22:11 ` [Patch v6 4/8] lib: add "verbose" versions of notmuch_database_{open,create} David Bremner
2015-03-28 10:04 ` [Patch v6 4/8] lib: add "verbose" versions of notmuch_database_{open, create} Tomi Ollila
2015-03-28 23:46 ` [Patch v6 4/8] lib: add "verbose" versions of notmuch_database_{open,create} David Bremner
2015-03-27 22:11 ` [Patch v6 5/8] lib: add a log function with output to a string in notmuch_database_t David Bremner
2015-03-27 22:11 ` [Patch v6 6/8] lib: add private function to extract the database for a message David Bremner
2015-03-27 22:11 ` [Patch v6 7/8] lib: replace almost all fprintfs in library with _n_d_log David Bremner
2015-03-27 22:12 ` [Patch v6 8/8] lib: eliminate fprintf from _notmuch_message_file_open David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427494320-1483-3-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).