I'm writing tests for an interactive function. I've been using the unread-command-events variable in conjunction with call-interactively to verify that it does the right thing.

However, I just discovered that this doesn't work in batch mode.

For example:

(defun my-dummy (s)
  (interactive "sWrite something: ")

(ert-deftest my-dummy-test ()
  (let ((unread-command-events (listify-key-sequence "Hi!\n")))
    (should (equal (call-interactively #'my-dummy)

When running ert in interactive mode, this works. However, in batch mode, Emacs stops and read the keyboard without consuming input from unread-command-events.

In this a bug in batch mode or is this the expected behaviour?

Is there any other way to do this in batch mode?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.