You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you accept a pull request with a function that takes a predicates and wait with a timeout for the predicate to be true ? I have a mode which is launching async commands to fill a buffer. In my test I need to wait for the buffer to be filled. I was thinking something along the lines of:
(defmacro ert-wait-for (timeout predicate &rest body)
"Wait for maximum TIMEOUT second for PREDICATE to verify, than execute forms in BODY."
`(with-timeout
(,timeout (ert-fail (format "Timeout of %ds exceeded while waiting for predicate." ,timeout)))
(while (not (funcall ,predicate))
(accept-process-output nil 0.05))
,@body))
So one could use it like
(ert-deftest test-buffer-content ()
(with-current-buffer my-buffer
(ert-wait-for 10 (lambda ()
(goto-char (point-min))
(= (how-many "foobar" 2)))
(goto-char (point-min))
(should (re-search-forward "the foobar is in the foobar" nil t)))))
to wait for a buffer to contain twice foobar for example. I think this might be usefull for other users of async commands.
The text was updated successfully, but these errors were encountered:
Yes the buffer content is the output of an async function started with start-process. But maybe I misunderstood this library purpose. If I understood correctly, with your lib, I could use a callback in my process sentinel and use ert-deftest-async to assert that the callback has been called before timeout. I found that, for me, going the way of the wait-for function was easier as it allows to also verify the side effect of the callback (like switching to a buffer or creating a new one). Anyway if you have a better suggestion, for my problem or for another library where this could be usefull, it's welcome.
Would you accept a pull request with a function that takes a predicates and wait with a timeout for the predicate to be true ? I have a mode which is launching async commands to fill a buffer. In my test I need to wait for the buffer to be filled. I was thinking something along the lines of:
So one could use it like
to wait for a buffer to contain twice foobar for example. I think this might be usefull for other users of async commands.
The text was updated successfully, but these errors were encountered: