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

View File

@ -8,16 +8,20 @@
;;; Code: ;;; 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) (defun assert-preview (puml output &optional format)
"Run PlantUML on the source PUML and asserts the result to be "Run PlantUML on the source PUML and asserts the result to be
equal to OUTPUT. Can choose the output FORMAT (default: utxt)." equal to OUTPUT. Can choose the output FORMAT (default: utxt)."
(if format (if format
(setq plantuml-output-type format) (setq plantuml-output-type format)
(setq plantuml-output-type "utxt")) (setq plantuml-output-type "utxt"))
(plantuml-preview-string 42 (read-test-file puml)) (plantuml-preview-string nil (read-test-file puml))
(sleep-for 3) (sleep-for 3)
(should (equal (replace-regexp-in-string " " "~" (read-test-file output)) (assert-preview-content (read-test-file output)))
(replace-regexp-in-string " " "~" (read-preview-buffer)))))
(defmacro test-and-cleanup-preview (&rest forms) (defmacro test-and-cleanup-preview (&rest forms)
"Run the test described in FORMS and eventually cleanup the preview buffer." "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") (setq-local plantuml-output-type "utxt")
(assert-preview "unicode.puml" "unicode.txt"))) (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) (provide 'plantuml-mode-preview-test)
;;; plantuml-mode-preview-test.el ends here ;;; plantuml-mode-preview-test.el ends here