[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Testing redisplay code in batch
From: |
Alan Mackenzie |
Subject: |
Re: Testing redisplay code in batch |
Date: |
Wed, 23 Sep 2020 10:50:45 +0000 |
Hello, Stefan.
On Tue, Sep 22, 2020 at 23:56:33 -0400, Stefan Monnier wrote:
> I have a test for the Bug#43519 which I'd like to add to our test suite,
> but it requires the redisplay to do its job, and in batch mode it seems
> that Mr. Redisplay gets quite sloppy.
> Does someone have experience with batch-tests of redisplay code?
> So far I've only use the "let-bind execute-kbd-macro to t" trick in
> order to convince minibuffer functions to actually use a minibuffer
> and process events from `unread-command-events`, but here I need to go
> further because I the "dummy windows" used in batch mode aren't
> good enough.
> So I'm ideally looking for a way to convince Emacs's internals to
> perform redisplay as if there were "real" windows. I don't need to
> "see/display" the result, OTOH because I only need to test things like
> `window-start` and `window-end` after calling `redisplay`.
> If that can't be done without major surgery to the C code, has someone
> already setup some way to run interactive tests in some virtual
> interactive session (I guess using something like a detached `screen` or
> `tmux`)?
Have a look at .../tests/000tests.el in standalone CC Mode. In
particular, look at this function (which has been in place for ~18
years):
(defun cc-test-force-font-lock-buffer ()
;; Try to forcibly font lock the current buffer, even in batch mode.
;; We're doing really dirty things to trick font-lock into action in
;; batch mode in the different emacsen.
(let ((orig-noninteractive-function
(and (fboundp 'noninteractive)
(symbol-function 'noninteractive)))
(orig-noninteractive-variable
(and (boundp 'noninteractive)
(symbol-value 'noninteractive)))
;; font-lock in XEmacs 19 looks at a variable named `noninteractive'.
(noninteractive nil))
(unwind-protect
(progn
(when orig-noninteractive-function
;; XEmacs (at least 21.4) calls `noninteractive' to check
;; for batch mode, so we let it lie.
(fset 'noninteractive (lambda () nil)))
(font-lock-mode 1)
(unless (or (get-text-property (point-min) 'face)
(next-single-property-change (point-min) 'face))
;; Some emacsen have already fontified the buffer above,
;; but others need some more coercion..
(let (;; Avoid getting some lazy fontification package that
;; might decide that nothing should be done.
(font-lock-fontify-buffer-function
'font-lock-default-fontify-buffer))
(font-lock-fontify-buffer))))
(when orig-noninteractive-function
(fset 'noninteractive orig-noninteractive-function)))))
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
Re: Testing redisplay code in batch,
Alan Mackenzie <=
Re: Testing redisplay code in batch, Eli Zaretskii, 2020/09/23