1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-26 07:33:39 +00:00

beginning tests for ob-exp, and related improvements to org-test

- fixed issue in creation of new files
  - fixed issue in org-test-in-file
  - new example file w/o any headlines
This commit is contained in:
Eric Schulte 2010-10-04 08:29:00 -06:00
parent 9bd5f511ce
commit 5bafe303aa
3 changed files with 65 additions and 10 deletions

View File

@ -0,0 +1,9 @@
This is an example file for use by the Org-mode tests.
This file is special because it has no headings, which can be
erroneously assumed by some code.
#+begin_src emacs-lisp :tangle no
;; 94839181-184f-4ff4-a72f-94214df6f5ba
(message "I am code")
#+end_src

View File

@ -0,0 +1,36 @@
;;; test-ob-exp.el
;; Copyright (c) 2010 Eric Schulte
;; Authors: Eric Schulte
;; Released under the GNU General Public License version 3
;; see: http://www.gnu.org/licenses/gpl-3.0.html
;;;; Comments:
;; Template test file for Org-mode tests
;;; Code:
(require 'org-test)
;;; Tests
(ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers ()
"Testing export without any headlines in the org-mode file."
(org-test-in-example-file org-test-no-header-example-file-name
;; export the file to html
(org-export-as-html nil)
;; should create a .html file
(should (file-exists-p (concat
(file-name-sans-extension
org-test-no-header-example-file-name)
".html")))
;; should not create a file with "::" appended to it's name
(should-not (file-exists-p
(concat org-test-no-header-example-file-name "::")))))
(provide 'test-ob-exp)
;;; test-ob-exp.el ends here

View File

@ -59,6 +59,9 @@ org-test searches this directory up the directory tree.")
(defconst org-test-example-file-name
(expand-file-name "example-file.org" org-test-dir))
(defconst org-test-no-header-example-file-name
(expand-file-name "example-file-no-header.org" org-test-dir))
;;; Functions for writing tests
@ -74,16 +77,20 @@ currently executed.")
(defmacro org-test-in-example-file (file &rest body)
"Execute body in the Org-mode example file."
(declare (indent 1))
`(let ((visited-p (get-file-buffer (or ,file org-test-example-file-name)))
to-be-removed)
`(let* ((my-file (or ,file org-test-example-file-name))
(visited-p (get-file-buffer my-file))
to-be-removed)
(save-window-excursion
(save-match-data
(find-file org-test-example-file-name)
(find-file my-file)
(setq to-be-removed (current-buffer))
(goto-char (point-min))
(outline-next-visible-heading 1)
(org-show-subtree)
(org-show-block-all)
(condition-case nil
(progn
(outline-next-visible-heading 1)
(org-show-subtree)
(org-show-block-all))
(error nil))
,@body))
(unless visited-p
(kill-buffer to-be-removed))))
@ -113,11 +120,12 @@ files."
(concat org-base-dir "/")
"Jump between org-mode files and their tests."
(lambda (path)
(let ((full-path (expand-file-name path org-base-dir))
(name (file-name-nondirectory path)))
(let* ((full-path (expand-file-name path org-base-dir))
(file-name (file-name-nondirectory path))
(name (file-name-sans-extension file-name)))
(find-file full-path)
(insert
";;; " name "\n\n"
";;; " file-name "\n\n"
";; Copyright (c) 2010 " user-full-name "\n"
";; Authors: " user-full-name "\n\n"
";; Released under the GNU General Public License version 3\n"
@ -133,7 +141,9 @@ files."
" \"Just an example to get you started.\"\n"
" (should t)\n"
" (should-not nil)\n"
" (should-error (error \"errr...\")))") full-path))
" (should-error (error \"errr...\")))\n\n\n"
"(provide '" name ")\n\n"
";;; " file-name " ends here\n") full-path))
(lambda () ((lambda (res) (if (listp res) (car res) res)) (which-function))))