From 1eb56441a2cdeee8f8be1b1e804e4beb1192e484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Bela=C3=AFche?= Date: Sun, 29 Mar 2026 14:58:50 +0200 Subject: [PATCH] Inter-thread synchronize command-loop vs after entry hook. * test/lisp/ses-tests.el (ses-tests--mutex) (ses-tests--condition, ses-tests--done): New object for inter-thread synchronisation. (ses-tests-snake-move): Add condition notification. (ses-tests-snake-move-after-entry): Add condition wait. --- test/lisp/ses-tests.el | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/lisp/ses-tests.el b/test/lisp/ses-tests.el index 0355c2fed87..bc5b5c63b4f 100644 --- a/test/lisp/ses-tests.el +++ b/test/lisp/ses-tests.el @@ -43,6 +43,14 @@ (defvar B2) (defvar ses--toto)) +;; Inter-thread synchronisation to wait for after entry hook completion +;; ---------------------------------------------------------------------- +(defvar ses-tests--mutex (make-mutex "ses-tests")) +(defvar ses-tests--condition (make-condition-variable ses-tests--mutex + (mutex-name ses-tests--mutex))) +(defvar ses-tests--done nil) + + ;; Check no border effects ;; ====================================================================== (defun ses-tests-check-no-border-effect () @@ -317,7 +325,10 @@ assuming a four columns sheet." (forward-char count)) (if (= ses-col 0) (next-line count) - (backward-char count)))) + (backward-char count))) + (with-mutex ses-tests--mutex + (setq ses-tests--done t) + (condition-notify ses-tests--condition))) (ert-deftest ses-tests-snake-move-after-entry () "\ @@ -339,7 +350,11 @@ has been built as expected. (dotimes (i 16) ;; fill the SES sheet with snake move (setq keys (concat (mapconcat #'string (number-to-string i) " ") " RET")) - (ert-play-keys keys) + (with-mutex ses-tests--mutex + (setq ses-tests--done nil) + (ert-play-keys keys) + (while (not ses-tests--done) + (condition-wait ses-tests--condition))) ;; build the snake move test vector (push i cols) (when (= (logand i 3) 3); when row is complete