Failing test, dunno why

This commit is contained in:
Carlo Sciolla 2017-08-27 12:51:23 +02:00
parent 5e6810adb6
commit 1c32cdbf54
No known key found for this signature in database
GPG Key ID: BA5D71E6F3C580C1
2 changed files with 23 additions and 12 deletions

View File

@ -247,8 +247,8 @@ to choose where to display it:
(let ((b (get-buffer plantuml-preview-buffer)))
(when b
(with-current-buffer b
(setq buffer-read-only nil)
(erase-buffer))))
(setq buffer-read-only nil)
(erase-buffer))))
(let* ((imagep (and (display-images-p)
(plantuml-is-image-output-p)))
@ -264,13 +264,13 @@ to choose where to display it:
(lambda (_ps event)
(unless (equal event "finished\n")
(error "PLANTUML Preview failed: %s" event))
(cond
((= prefix 16)
(switch-to-buffer-other-frame plantuml-preview-buffer))
((= prefix 4)
(switch-to-buffer plantuml-preview-buffer))
(t (switch-to-buffer-other-window plantuml-preview-buffer)))
(if (numberp prefix)
(cond
((= prefix 16)
(switch-to-buffer-other-frame plantuml-preview-buffer))
((= prefix 4)
(switch-to-buffer plantuml-preview-buffer)))
(switch-to-buffer-other-window plantuml-preview-buffer))
(when imagep
(image-mode)
(set-buffer-multibyte t)))))))

View File

@ -8,16 +8,20 @@
;;; Code:
(defun assert-preview-content (expected)
"Assert the contents of the preview buffer to be equal to EXPECTED."
(should (equal (replace-regexp-in-string " " "~" expected)
(replace-regexp-in-string " " "~" (read-preview-buffer)))))
(defun assert-preview (puml output &optional format)
"Run PlantUML on the source PUML and asserts the result to be
equal to OUTPUT. Can choose the output FORMAT (default: utxt)."
(if format
(setq plantuml-output-type format)
(setq plantuml-output-type "utxt"))
(plantuml-preview-string 42 (read-test-file puml))
(plantuml-preview-string nil (read-test-file puml))
(sleep-for 3)
(should (equal (replace-regexp-in-string " " "~" (read-test-file output))
(replace-regexp-in-string " " "~" (read-preview-buffer)))))
(assert-preview-content (read-test-file output)))
(defmacro test-and-cleanup-preview (&rest forms)
"Run the test described in FORMS and eventually cleanup the preview buffer."
@ -37,6 +41,13 @@ equal to OUTPUT. Can choose the output FORMAT (default: utxt)."
(setq-local plantuml-output-type "utxt")
(assert-preview "unicode.puml" "unicode.txt")))
(ert-deftest preview-new-window()
(test-and-cleanup-preview
(save-window-excursion
(open-test-file-in-buf "a-b.puml")
(plantuml-preview nil)
(sleep-for 3))))
(provide 'plantuml-mode-preview-test)
;;; plantuml-mode-preview-test.el ends here