Skip to content

Commit

Permalink
Merge pull request #789 from jrblevin/fix-tests-for-latest-emacs
Browse files Browse the repository at this point in the history
Fix tests for Emacs 30
  • Loading branch information
syohex committed Aug 8, 2023
2 parents b403120 + 8c7b5c5 commit 5e15541
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(require 'ert)
(require 'cl-lib)
(require 'ispell)
(require 'eww)

(eval-when-compile
;; This is for byte-compile warnings on older Emacs.
Expand Down Expand Up @@ -6864,25 +6865,20 @@ Detail: https://github.com/jrblevin/markdown-mode/pull/590"
(should (string= (buffer-name) "doesnotexist.md")))
(kill-buffer))))

(defadvice markdown-live-preview-window-eww
(around markdown-test-create-fake-eww disable)
(setq ad-return-value (get-buffer-create "*eww*")))
(defun markdown-test-live-preview-window-eww (_orig-fun &rest _args)
(get-buffer-create "*eww*"))

(defmacro markdown-test-fake-eww (&rest body)
`(progn
,@(if (and (fboundp 'libxml-parse-html-region) (require 'eww nil t)) body
`((ad-enable-advice #'markdown-live-preview-window-eww
'around 'markdown-test-create-fake-eww)
(ad-activate #'markdown-live-preview-window-eww)
,@(if (fboundp 'libxml-parse-html-region)
body
`((advice-add 'markdown-live-preview-window-eww :around #'markdown-test-live-preview-window-eww)
,@body
(ad-disable-advice #'markdown-live-preview-window-eww
'around 'markdown-test-create-fake-eww)
(ad-activate #'markdown-live-preview-window-eww)))))
(advice-remove 'markdown-live-preview-window-eww #'markdown-test-live-preview-window-eww)))))

(defmacro markdown-test-eww-or-nothing (test &rest body)
(declare (indent 1))
(if (and (fboundp 'libxml-parse-html-region) (require 'eww nil t)
(executable-find markdown-command))
(if (and (fboundp 'libxml-parse-html-region) (executable-find markdown-command))
`(progn ,@body)
(message "no eww, no libxml2, or no %s found: skipping %s" markdown-command test)
nil))
Expand Down

0 comments on commit 5e15541

Please sign in to comment.