Build-only: let the collocatordb tests find the staged library

Change-Id: Id54f4de8b132048c2f5ab42cc7e11a0359fa1179
diff --git a/scripts/install.sh b/scripts/install.sh
index 33a2a22..cb1417b 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -198,7 +198,15 @@
     fi
 fi
 if [ $SKIP_TESTS = 0 ]; then
-    ctest --test-dir "$WORK/collocatordb/build" --output-on-failure
+    if [ -n "$CDB_STAGE" ]; then
+        # staged, not installed, and no ldconfig - the test binaries find the
+        # shared collocatordb in the build directory
+        env LD_LIBRARY_PATH="$WORK/collocatordb/build${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
+            DYLD_LIBRARY_PATH="$WORK/collocatordb/build${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" \
+            ctest --test-dir "$WORK/collocatordb/build" --output-on-failure
+    else
+        ctest --test-dir "$WORK/collocatordb/build" --output-on-failure
+    fi
 fi
 
 # --- 4. dereko2vec -----------------------------------------------------------