diff options
| author | Mattias EngdegÄrd | 2022-05-30 12:25:19 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-05-30 15:52:02 +0200 |
| commit | 169797a3002fae1e86ee799475cd4f1b7ef9a3d1 (patch) | |
| tree | 10a3b1f0b2509520dc4839e41f8d112317377f33 /test/src | |
| parent | 78e8893f5d4b1c9ca5742fbe20bc5d05a843ed4e (diff) | |
| download | emacs-169797a3002fae1e86ee799475cd4f1b7ef9a3d1.tar.gz emacs-169797a3002fae1e86ee799475cd4f1b7ef9a3d1.zip | |
Fix atimer setting and overdue expiration (bug#55628)
* src/atimer.c (set_alarm): If the atimer has already expired, signal
it right away instead of postponing it further. Previously this could
occur repeatedly, blocking atimers indefinitely.
Also only use `alarm` as fallback if `setitimer` is unavailable, not
both at the same time (which makes no sense, and they both typically
use the same mechanism behind the curtains).
* test/src/eval-tests.el (eval-tests/funcall-with-delayed-message):
New test, verifying proper functioning of funcall-with-delayed-message
which also serves as test for this bug (which also caused
debug-timer-check to fail, but that test is only run when Emacs is
built with enable-checking).
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/eval-tests.el | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index e4230c10efd..1b2ad99360b 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -240,4 +240,31 @@ expressions works for identifiers starting with period." | |||
| 240 | (should (equal (string-trim (buffer-string)) | 240 | (should (equal (string-trim (buffer-string)) |
| 241 | "Error: (error \"Boo\")"))))) | 241 | "Error: (error \"Boo\")"))))) |
| 242 | 242 | ||
| 243 | (ert-deftest eval-tests/funcall-with-delayed-message () | ||
| 244 | ;; Check that `funcall-with-delayed-message' displays its message before | ||
| 245 | ;; its function terminates iff the timeout is short enough. | ||
| 246 | |||
| 247 | ;; This also serves as regression test for bug#55628 where a short | ||
| 248 | ;; timeout was rounded up to the next whole second. | ||
| 249 | (dolist (params '((0.8 0.4) | ||
| 250 | (0.1 0.8))) | ||
| 251 | (let ((timeout (nth 0 params)) | ||
| 252 | (work-time (nth 1 params))) | ||
| 253 | (ert-info ((prin1-to-string params) :prefix "params: ") | ||
| 254 | (with-current-buffer "*Messages*" | ||
| 255 | (let ((inhibit-read-only t)) | ||
| 256 | (erase-buffer)) | ||
| 257 | (let ((stop (+ (float-time) work-time))) | ||
| 258 | (funcall-with-delayed-message | ||
| 259 | timeout "timed out" | ||
| 260 | (lambda () | ||
| 261 | (while (< (float-time) stop)) | ||
| 262 | (message "finished")))) | ||
| 263 | (let ((expected-messages | ||
| 264 | (if (< timeout work-time) | ||
| 265 | "timed out\nfinished" | ||
| 266 | "finished"))) | ||
| 267 | (should (equal (string-trim (buffer-string)) | ||
| 268 | expected-messages)))))))) | ||
| 269 | |||
| 243 | ;;; eval-tests.el ends here | 270 | ;;; eval-tests.el ends here |