Better test docs and cleanup
This commit is contained in:
parent
17fc31d7f8
commit
bb33ce840f
|
@ -246,7 +246,9 @@ to choose where to display it:
|
|||
- else -> new window"
|
||||
(let ((b (get-buffer plantuml-preview-buffer)))
|
||||
(when b
|
||||
(kill-buffer b)))
|
||||
(with-current-buffer b
|
||||
(setq buffer-read-only nil)
|
||||
(erase-buffer))))
|
||||
|
||||
(let* ((imagep (and (display-images-p)
|
||||
(plantuml-is-image-output-p)))
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
;;; Code:
|
||||
|
||||
(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"))
|
||||
|
@ -18,13 +20,19 @@
|
|||
(replace-regexp-in-string " " "~" (read-preview-buffer)))))
|
||||
|
||||
(ert-deftest preview-utxt-test ()
|
||||
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
||||
(assert-preview "a-b.puml" "a-b.txt"))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
||||
(assert-preview "a-b.puml" "a-b.txt"))
|
||||
(cleanup-preview)))
|
||||
|
||||
(ert-deftest preview-unicode-test ()
|
||||
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
||||
(setq-local plantuml-output-type "utxt")
|
||||
(assert-preview "unicode.puml" "unicode.txt"))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
||||
(setq-local plantuml-output-type "utxt")
|
||||
(assert-preview "unicode.puml" "unicode.txt")))
|
||||
(cleanup-preview))
|
||||
|
||||
(provide 'plantuml-mode-preview-test)
|
||||
|
||||
|
|
|
@ -22,17 +22,38 @@
|
|||
(defvar plantuml-test-jar-path
|
||||
(f-join package-code-path "bin/plantuml.jar"))
|
||||
|
||||
(defun test-file-path (path)
|
||||
"Translate the relative test path PATH in an absolute path."
|
||||
(f-join plantuml-test-resources-path path))
|
||||
|
||||
(defun cleanup-preview ()
|
||||
"Kill the preview buffer"
|
||||
(let ((proc (get-buffer-process plantuml-preview-buffer)))
|
||||
(when proc
|
||||
(set-process-query-on-exit-flag proc nil))
|
||||
(kill-buffer plantuml-preview-buffer)))
|
||||
|
||||
(defun read-buffer (bufname)
|
||||
"Read the contents of buffer BUFNAME."
|
||||
(with-current-buffer (get-buffer bufname)
|
||||
(buffer-string)))
|
||||
|
||||
(defun read-preview-buffer ()
|
||||
"Read the contents of the PlantUML preview buffer."
|
||||
(read-buffer plantuml-preview-buffer))
|
||||
|
||||
(defun read-test-file (path)
|
||||
(f-read (f-join plantuml-test-resources-path path) 'utf-8))
|
||||
"Fetch the string content of the test file at relative path PATH."
|
||||
(f-read (test-file-path path) 'utf-8))
|
||||
|
||||
(defun open-test-file-in-buf (test-file)
|
||||
"Visit TEST-FILE in a new buffer."
|
||||
(message "buffer list before: %s" (buffer-list))
|
||||
(find-file (test-file-path test-file))
|
||||
(message "buffer list after: %s" (buffer-list)))
|
||||
|
||||
(defun load-plantuml-mode ()
|
||||
"Load the plantuml-mode package."
|
||||
(require 'plantuml-mode (f-expand "plantuml-mode.el" package-code-path)))
|
||||
|
||||
(load-plantuml-mode)
|
||||
|
|
Loading…
Reference in New Issue