Skip to content

Commit b6b34a0

Browse files
author
Danny McClanahan
committed
fix waiting for async
1 parent 850a4c1 commit b6b34a0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tests/markdown-test.el

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,24 +3299,29 @@ indented the same amount."
32993299
'around 'markdown-create-fake-eww)
33003300
(ad-activate #'markdown-live-preview-window-eww)))))
33013301

3302+
(defun markdown-test/live-preview-wait ()
3303+
(unless markdown-live-preview-current-buffer-sync-async
3304+
(sit-for (* markdown-live-preview-idle-delay 10))
3305+
(accept-process-output)))
3306+
33023307
(defun markdown-test/live-preview-exports ()
33033308
(markdown-test-temp-file "inline.text"
33043309
(unless (require 'eww nil t)
33053310
(should-error (markdown-live-preview-mode)))
33063311
(let ((markdown-live-preview-idle-delay .01))
33073312
(markdown-temp-eww
33083313
(markdown-live-preview-mode)
3309-
(sit-for (* markdown-live-preview-idle-delay 3))
3310-
(accept-process-output)
3314+
(markdown-test/live-preview-wait)
33113315
(should (buffer-live-p markdown-live-preview-view-buffer))
33123316
(should (eq (current-buffer)
33133317
(with-current-buffer markdown-live-preview-view-buffer
33143318
markdown-live-preview-source-buffer)))
33153319
(kill-buffer markdown-live-preview-view-buffer)
33163320
(should (null markdown-live-preview-view-buffer))
3317-
(markdown-live-preview-async-export)
3318-
(sit-for (* markdown-live-preview-idle-delay 3))
3319-
(accept-process-output)
3321+
(if markdown-live-preview-current-buffer-sync-async
3322+
(markdown-live-preview-sync-export)
3323+
(markdown-live-preview-async-export)
3324+
(markdown-test/live-preview-wait))
33203325
(should (buffer-live-p markdown-live-preview-view-buffer))))))
33213326

33223327
(ert-deftest test-markdown-ext/live-preview-exports-sync ()
@@ -3333,22 +3338,19 @@ indented the same amount."
33333338
(let ((markdown-live-preview-delete-export 'delete-on-destroy))
33343339
(markdown-test-temp-file "inline.text"
33353340
(markdown-live-preview-mode)
3336-
(sit-for (* markdown-live-preview-idle-delay 3))
3337-
(accept-process-output)
3341+
(markdown-test/live-preview-wait)
33383342
(setq file-output (markdown-export-file-name)))
33393343
(should-not (file-exists-p file-output)))
33403344
(let ((markdown-live-preview-delete-export 'delete-on-export))
33413345
(markdown-test-temp-file "inline.text"
33423346
(markdown-live-preview-mode)
3343-
(sit-for (* markdown-live-preview-idle-delay 3))
3344-
(accept-process-output)
3347+
(markdown-test/live-preview-wait)
33453348
(setq file-output (markdown-export-file-name))
33463349
(should-not (file-exists-p file-output))))
33473350
(unwind-protect
33483351
(markdown-test-temp-file "inline.text"
33493352
(markdown-live-preview-mode)
3350-
(sit-for (* markdown-live-preview-idle-delay 3))
3351-
(accept-process-output)
3353+
(markdown-test/live-preview-wait)
33523354
(setq file-output (markdown-export-file-name))
33533355
(setq markdown-live-preview-delete-export nil)
33543356
(should (file-exists-p file-output)))

0 commit comments

Comments
 (0)