new testing macro for in-file execution with temp text

* testing/org-test.el (org-test-with-temp-text-in-file): A new testing
  macros for temp-text tests which require a file name (e.g., for
  export).
This commit is contained in:
Eric Schulte 2011-11-18 11:29:47 -07:00
parent e28e1038c4
commit 1f206ed477
1 changed files with 18 additions and 0 deletions

View File

@ -180,6 +180,7 @@ files."
(goto-char (point-min))
(re-search-forward (regexp-quote ,marker))
,@body))
(def-edebug-spec org-test-at-marker (form form body))
(defmacro org-test-with-temp-text (text &rest body)
"Run body in a temporary buffer with Org-mode as the active
@ -197,6 +198,23 @@ otherwise place the point at the beginning of the inserted text."
`(progn (insert ,inside-text)
(goto-char (point-min)))))
,@body)))
(def-edebug-spec org-test-with-temp-text (form body))
(defmacro org-test-with-temp-text-in-file (text &rest body)
"Run body in a temporary file buffer with Org-mode as the active mode."
(declare (indent 1))
(let ((file (make-temp-file "org-test"))
(inside-text (if (stringp text) text (eval text)))
(results (gensym)))
`(let ((kill-buffer-query-functions nil) ,results)
(with-temp-file ,file (insert ,inside-text))
(find-file ,file)
(org-mode)
(setq ,results ,@body)
(save-buffer) (kill-buffer)
(delete-file ,file)
,results)))
(def-edebug-spec org-test-with-temp-text-in-file (form body))
;;; Navigation Functions