test: set LD_LIBRARY_PATH early and keep its old contents
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 25 May 2016 21:37:40 +0000 (00:37 +0300)
committerDavid Bremner <david@tethera.net>
Sat, 11 Jun 2016 16:11:49 +0000 (13:11 -0300)
Previously LD_LIBRARY_PATH was exported (and environment changed)
in the middle of test case execution, when a function setting it
was called.

Previously the old contents of LD_LIBRARY_PATH was lost (if any)
when it was re-set and exported. In some systems the old contents of
LD_LIBRARY_PATH was needed to e.g. locate suitable gmime library.

test/T360-symbol-hiding.sh
test/test-lib-common.sh
test/test-lib.sh

index e681d5b33250bf30e6a9b9642309d508304a0368..b3dbb1b543e9e0a9e8d83821ddf1e182f5fb0a57 100755 (executable)
@@ -13,9 +13,8 @@ test_description='exception symbol hiding'
 
 test_begin_subtest 'running test' run_test
 mkdir -p ${PWD}/fakedb/.notmuch
-( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
-                $TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \
-                2>&1 | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g") > OUTPUT
+$TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent 2>&1 \
+       | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g" > OUTPUT
 
 cat <<EOF > EXPECTED
 A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian'
index 0fdeeb72479252618fec80a7fa62a792287d5e01..03ef1d2d02467674f4f096fcd872a409fe7421fe 100644 (file)
@@ -58,6 +58,11 @@ restore_database () {
 TEST_DIRECTORY=$(pwd -P)
 notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
 
+# Prepend $TEST_DIRECTORY/../lib to LD_LIBRARY_PATH, to make tests work
+# on systems where ../notmuch depends on LD_LIBRARY_PATH.
+LD_LIBRARY_PATH=${TEST_DIRECTORY%/*}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
+export LD_LIBRARY_PATH
+
 # configure output
 . $notmuch_path/sh.config || exit 1
 
index 4a8ef1f46b478b376728b3c15965fbddf9a4a9df..b0ee253c94426290373711dbbe946ed7f9935ff6 100644 (file)
@@ -1192,7 +1192,6 @@ test_emacs () {
 }
 
 test_python() {
-       export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
        export PYTHONPATH=$TEST_DIRECTORY/../bindings/python
 
        (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \
@@ -1200,7 +1199,6 @@ test_python() {
 }
 
 test_ruby() {
-    export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
     MAIL_DIR=$MAIL_DIR ruby -I $TEST_DIRECTORY/../bindings/ruby> OUTPUT
 }
 
@@ -1208,7 +1206,6 @@ 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