From 92d89beac1ee869613773c1944f9358ef4989a23 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 14 Dec 2024 09:37:17 +0100 Subject: [PATCH] Fix xt-mouse-tests.el in interactive mode * test/lisp/xt-mouse-tests.el (with-xterm-mouse-mode): Run only when noninteractive. (cherry picked from commit 83245d2269be357db2fff8baa17adb4b05f97aed) --- test/lisp/xt-mouse-tests.el | 53 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/test/lisp/xt-mouse-tests.el b/test/lisp/xt-mouse-tests.el index f64b3aed73e..0610b6f94c5 100644 --- a/test/lisp/xt-mouse-tests.el +++ b/test/lisp/xt-mouse-tests.el @@ -30,32 +30,33 @@ (defmacro with-xterm-mouse-mode (&rest body) "Run BODY with `xterm-mouse-mode' temporarily enabled." (declare (indent 0)) - `(let ((width (frame-width)) - (height (frame-height))) - (unwind-protect - (progn - ;; Make the frame huge so that the test input events below - ;; don't hit the menu bar. - (set-frame-width nil (max width 2000)) - (set-frame-height nil (max height 2000)) - (cl-letf (;; Reset XTerm parameters so that the tests don't - ;; get confused. - ((terminal-parameter nil 'xterm-mouse-x) nil) - ((terminal-parameter nil 'xterm-mouse-y) nil) - ((terminal-parameter nil 'xterm-mouse-last-down) nil) - ((terminal-parameter nil 'xterm-mouse-last-click) nil)) - (unwind-protect - (progn - ;; `xterm-mouse-mode' doesn't work in the initial - ;; terminal. Since we can't create a second - ;; terminal in batch mode, fake it temporarily. - (cl-letf (((symbol-function 'terminal-name) - (lambda (&optional _terminal) "fake-terminal"))) - (xterm-mouse-mode 1)) - ,@body) - (xterm-mouse-mode 0)))) - (set-frame-width nil width) - (set-frame-height nil height)))) + (when noninteractive + `(let ((width (frame-width)) + (height (frame-height))) + (unwind-protect + (progn + ;; Make the frame huge so that the test input events below + ;; don't hit the menu bar. + (set-frame-width nil (max width 2000)) + (set-frame-height nil (max height 2000)) + (cl-letf (;; Reset XTerm parameters so that the tests don't + ;; get confused. + ((terminal-parameter nil 'xterm-mouse-x) nil) + ((terminal-parameter nil 'xterm-mouse-y) nil) + ((terminal-parameter nil 'xterm-mouse-last-down) nil) + ((terminal-parameter nil 'xterm-mouse-last-click) nil)) + (unwind-protect + (progn + ;; `xterm-mouse-mode' doesn't work in the initial + ;; terminal. Since we can't create a second + ;; terminal in batch mode, fake it temporarily. + (cl-letf (((symbol-function 'terminal-name) + (lambda (&optional _terminal) "fake-terminal"))) + (xterm-mouse-mode 1)) + ,@body) + (xterm-mouse-mode 0)))) + (set-frame-width nil width) + (set-frame-height nil height))))) (ert-deftest xt-mouse-tracking-basic () (should (equal (xterm-mouse-tracking-enable-sequence) -- 2.39.2