X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;h=e2e26e6f274a1260ac570b09cd92f27ae90f1478;hp=b0ee253c94426290373711dbbe946ed7f9935ff6;hb=971cdc72cdb80f060193bc0914dc9badcc29696b;hpb=f0e5317bcdc856739c5107705e3bc86b31b01d38 diff --git a/test/test-lib.sh b/test/test-lib.sh index b0ee253c..e2e26e6f 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -541,21 +541,26 @@ emacs_fcc_message () notmuch new >/dev/null } -# Generate a corpus of email and add it to the database. +# Add an existing, fixed corpus of email to the database. # -# This corpus is fixed, (it happens to be 50 messages from early in -# the history of the notmuch mailing list), which allows for reliably +# $1 is the corpus dir under corpora to add, using "default" if unset. +# +# The default corpus is based on about 50 messages from early in the +# history of the notmuch mailing list, which allows for reliably # testing commands that need to operate on a not-totally-trivial # number of messages. add_email_corpus () { + corpus=${1:-default} + rm -rf ${MAIL_DIR} - if [ -d $TEST_DIRECTORY/corpus.mail ]; then - cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR} + if [ -d $TEST_DIRECTORY/corpora.mail/$corpus ]; then + cp -a $TEST_DIRECTORY/corpora.mail/$corpus ${MAIL_DIR} else - cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR} + cp -a $TEST_DIRECTORY/corpora/$corpus ${MAIL_DIR} notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus" - cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail + mkdir -p $TEST_DIRECTORY/corpora.mail + cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpora.mail/$corpus fi } @@ -1192,10 +1197,10 @@ test_emacs () { } test_python() { - export PYTHONPATH=$TEST_DIRECTORY/../bindings/python - - (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ - | $NOTMUCH_PYTHON - + # Note: if there is need to print debug information from python program, + # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w') + PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ + $NOTMUCH_PYTHON -B - > OUTPUT } test_ruby() { @@ -1206,7 +1211,7 @@ test_C () { exec_file="test${test_count}" test_file="${exec_file}.c" cat > ${test_file} - ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc + ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -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