branch: elpa/jabber
commit 44893727ccbe14b1dc583e5bb9e53a8caeed982d
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>
tests: Never open the user's real database from the suite
---
Makefile | 4 ++++
tests/jabber-test-message-correct.el | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 2383b74898..7b22090e9e 100644
--- a/Makefile
+++ b/Makefile
@@ -149,8 +149,11 @@ do-test: autoload do-module
@mkdir -p $(TEST_RESULTS)
@$(MAKE) --no-print-directory -j$(JOBS) -Otarget do-test-summary
+# jabber-db-path is preset to nil so no test can ever open the user's
+# real database; tests that need storage let-bind it to a temp file.
$(TEST_RESULTS)/%.stamp: tests/%.el
@output=$$($(EMACS_CMD) $(EMACS_OPTS) -L lisp -L tests \
+ --eval="(setq jabber-db-path nil)" \
-l ert -l $< -f ert-run-tests-batch-and-exit 2>&1); \
rc=$$?; \
n=$$(echo "$$output" | grep -o 'Ran [0-9]*' | grep -o '[0-9]*'); \
@@ -172,6 +175,7 @@ test-oneshot:
# `do-test' runs (one Emacs per file) cannot see.
do-test-oneshot: autoload do-module
$(EMACS_CMD) $(EMACS_OPTS) -L lisp -L tests -l ert \
+ --eval="(setq jabber-db-path nil)" \
--eval="(require 'jabber)" \
$(addprefix -l ,$(TESTS)) \
--eval="(let ((bad 0)) \
diff --git a/tests/jabber-test-message-correct.el
b/tests/jabber-test-message-correct.el
index f4154a20fa..f4426c1768 100644
--- a/tests/jabber-test-message-correct.el
+++ b/tests/jabber-test-message-correct.el
@@ -461,7 +461,12 @@ jabber-correct-last-message must pick up the original id."
:edited t
:timestamp (current-time))))
(jabber-chat-ewoc-enter (list :local msg)))
- (let (sent-replace-id)
+ ;; jabber-correct-last-message runs the full send-hook chain;
+ ;; disable storage so the DB outgoing handler cannot touch the
+ ;; user's real database.
+ (let ((jabber-db-path nil)
+ (jabber-db--connection nil)
+ sent-replace-id)
(cl-letf (((symbol-function 'jabber-send-sexp)
(lambda (_jc stanza)
(let* ((replace (car (jabber-xml-get-children stanza
'replace))))