unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Need message-fn arg back in ert-run-tests-interactively
@ 2023-07-09 15:49 Robert Weiner
  2023-07-11  6:18 ` Robert Weiner
  2023-09-05 22:43 ` Stefan Kangas
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Weiner @ 2023-07-09 15:49 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lidell Mats

[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]

In ert.el of Emacs 27.1, we have a simple ability to override the 'message'
function when running ert tests interactively by setting the message-fn
argument here:

;; Should OUTPUT-BUFFER-NAME and MESSAGE-FN really be arguments here?
;; They are needed only for our automated self-tests at the moment.
;; Or should there be some other mechanism?
;;;###autoload
(defun ert-run-tests-interactively (selector
                                    &optional output-buffer-name message-fn)

But in recent Emacs versions this function takes only the selector
argument, with no clear way of how to override messaging behavior so that a
message from a test case (rather than ert itself) can remain in the
minibuffer after a test case finishes:

(defun ert-run-tests-interactively (selector)
  "Run the tests specified by SELECTOR and display the results in a buffer.

SELECTOR works as described in `ert-select-tests'."

This would be very useful behavior to have back.  Is there any simple way
to do it now or can you add it back in?

Thanks,

Bob

[-- Attachment #2: Type: text/html, Size: 2177 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Need message-fn arg back in ert-run-tests-interactively
  2023-07-09 15:49 Need message-fn arg back in ert-run-tests-interactively Robert Weiner
@ 2023-07-11  6:18 ` Robert Weiner
  2023-09-05 22:43 ` Stefan Kangas
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Weiner @ 2023-07-11  6:18 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lidell Mats

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

Hi Guys:

Anyone have any thoughts on this?  Eli or Stefan?  Would be useful in some
updates we'd like to make to the Hyperbole package.

Regards,

Bob


On Sun, Jul 9, 2023 at 11:49 AM Robert Weiner <rsw@gnu.org> wrote:

> In ert.el of Emacs 27.1, we have a simple ability to override the
> 'message' function when running ert tests interactively by setting the
> message-fn argument here:
>
> ;; Should OUTPUT-BUFFER-NAME and MESSAGE-FN really be arguments here?
> ;; They are needed only for our automated self-tests at the moment.
> ;; Or should there be some other mechanism?
> ;;;###autoload
> (defun ert-run-tests-interactively (selector
>                                     &optional output-buffer-name
> message-fn)
>
> But in recent Emacs versions this function takes only the selector
> argument, with no clear way of how to override messaging behavior so that a
> message from a test case (rather than ert itself) can remain in the
> minibuffer after a test case finishes:
>
> (defun ert-run-tests-interactively (selector)
>   "Run the tests specified by SELECTOR and display the results in a buffer.
>
> SELECTOR works as described in `ert-select-tests'."
>
> This would be very useful behavior to have back.  Is there any simple way
> to do it now or can you add it back in?
>
> Thanks,
>
> Bob
>
>

[-- Attachment #2: Type: text/html, Size: 2984 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Need message-fn arg back in ert-run-tests-interactively
  2023-07-09 15:49 Need message-fn arg back in ert-run-tests-interactively Robert Weiner
  2023-07-11  6:18 ` Robert Weiner
@ 2023-09-05 22:43 ` Stefan Kangas
  2023-09-07  1:21   ` Richard Stallman
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2023-09-05 22:43 UTC (permalink / raw)
  To: rswgnu, emacs-devel; +Cc: Lidell Mats

Robert Weiner <rsw@gnu.org> writes:

> In ert.el of Emacs 27.1, we have a simple ability to override the 'message'
> function when running ert tests interactively by setting the message-fn
> argument here:
>
> ;; Should OUTPUT-BUFFER-NAME and MESSAGE-FN really be arguments here?
> ;; They are needed only for our automated self-tests at the moment.
> ;; Or should there be some other mechanism?
> ;;;###autoload
> (defun ert-run-tests-interactively (selector
>                                     &optional output-buffer-name message-fn)
>
> But in recent Emacs versions this function takes only the selector
> argument, with no clear way of how to override messaging behavior so that a
> message from a test case (rather than ert itself) can remain in the
> minibuffer after a test case finishes:
>
> (defun ert-run-tests-interactively (selector)
>   "Run the tests specified by SELECTOR and display the results in a buffer.
>
> SELECTOR works as described in `ert-select-tests'."
>
> This would be very useful behavior to have back.  Is there any simple way
> to do it now or can you add it back in?

You can use something like this:

    (cl-letf (((symbol-function 'message)
               (lambda (format-string &rest args)
                 ...)))
      (ert-run-tests-interactively t))

This should work on both new and old versions of Emacs.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Need message-fn arg back in ert-run-tests-interactively
  2023-09-05 22:43 ` Stefan Kangas
@ 2023-09-07  1:21   ` Richard Stallman
  2023-09-07  6:22     ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2023-09-07  1:21 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: rswgnu, emacs-devel, matsl

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > You can use something like this:

  >     (cl-letf (((symbol-function 'message)
  >                (lambda (format-string &rest args)
  >                  ...)))
  >       (ert-run-tests-interactively t))

It might work, but dynamically binding the function cell of a standard
Emacs Lisp function is very unclean.  Can wecome up with a cleaner way
to do this job?
 
-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Need message-fn arg back in ert-run-tests-interactively
  2023-09-07  1:21   ` Richard Stallman
@ 2023-09-07  6:22     ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2023-09-07  6:22 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Stefan Kangas, rswgnu, emacs-devel, matsl

>>     (cl-letf (((symbol-function 'message)
>>                (lambda (format-string &rest args)
>>                  ...)))
>>       (ert-run-tests-interactively t))
>
> It might work, but dynamically binding the function cell of a standard
> Emacs Lisp function is very unclean.  Can wecome up with a cleaner way
> to do this job?

There is set-message-function added in Emacs 27.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-07  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-09 15:49 Need message-fn arg back in ert-run-tests-interactively Robert Weiner
2023-07-11  6:18 ` Robert Weiner
2023-09-05 22:43 ` Stefan Kangas
2023-09-07  1:21   ` Richard Stallman
2023-09-07  6:22     ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).