ob-exp: fixed export when headings have links, with tests
also some organization of the test directory * lisp/ob-exp.el (org-babel-exp-src-blocks): fixed export when headings have links, with tests
This commit is contained in:
parent
41cde9d9bd
commit
e1b90eea45
|
@ -119,7 +119,11 @@ none ----- do not display either code or results upon export"
|
|||
;; attempt to go to the same heading in the original file
|
||||
(set-buffer (get-file-buffer org-current-export-file))
|
||||
(save-restriction
|
||||
(org-open-link-from-string link)
|
||||
(condition-case nil
|
||||
(org-open-link-from-string link)
|
||||
(error (when heading
|
||||
(goto-char (point-min))
|
||||
(re-search-forward (regexp-quote heading) nil t))))
|
||||
(setf (nth 2 info)
|
||||
(org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
|
|
|
@ -13,20 +13,23 @@
|
|||
|
||||
;;; Code:
|
||||
(require 'org-test)
|
||||
(require 'org-test-ob-consts)
|
||||
|
||||
|
||||
;;; 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-file
|
||||
;; export the file to html
|
||||
(org-export-as-html nil)
|
||||
(let ((html-file (concat (file-name-sans-extension org-test-no-heading-file)
|
||||
".html")))
|
||||
(when (file-exists-p html-file) (delete-file html-file))
|
||||
(org-test-in-example-file org-test-no-heading-file
|
||||
;; 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-file)
|
||||
".html")))
|
||||
(should (file-exists-p html-file))
|
||||
;; should not create a file with "::" appended to it's name
|
||||
(should-not (file-exists-p (concat org-test-no-header-file "::")))))
|
||||
(should-not (file-exists-p (concat org-test-no-heading-file "::")))
|
||||
(when (file-exists-p html-file) (delete-file html-file))))
|
||||
|
||||
(ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-file ()
|
||||
"Testing export from buffers which are not visiting any file."
|
||||
|
@ -39,10 +42,25 @@
|
|||
;; should contain the content of the buffer
|
||||
(save-excursion
|
||||
(set-buffer (get-buffer "*Org HTML Export*"))
|
||||
(should (string-match (regexp-quote test-org-code-block-anchor)
|
||||
(should (string-match (regexp-quote org-test-file-ob-anchor)
|
||||
(buffer-string))))
|
||||
(when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*")))
|
||||
|
||||
(ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers ()
|
||||
"Testing export without any headlines in the org-mode file."
|
||||
(let ((html-file (concat (file-name-sans-extension
|
||||
org-test-link-in-heading-file)
|
||||
".html")))
|
||||
(when (file-exists-p html-file) (delete-file html-file))
|
||||
(org-test-in-example-file org-test-link-in-heading-file
|
||||
;; export the file to html
|
||||
(org-export-as-html nil))
|
||||
;; should create a .html file
|
||||
(should (file-exists-p html-file))
|
||||
;; should not create a file with "::" appended to it's name
|
||||
(should-not (file-exists-p (concat org-test-link-in-heading-file "::")))
|
||||
(when (file-exists-p html-file) (delete-file html-file))))
|
||||
|
||||
(provide 'test-ob-exp)
|
||||
|
||||
;;; test-ob-exp.el ends here
|
||||
|
|
|
@ -13,20 +13,21 @@
|
|||
|
||||
;;; Code:
|
||||
(require 'org-test)
|
||||
(require 'org-test-ob-consts)
|
||||
|
||||
(ert-deftest test-org-babel-get-src-block-info-language ()
|
||||
(org-test-at-marker nil test-org-code-block-anchor
|
||||
(org-test-at-marker nil org-test-file-ob-anchor
|
||||
(let ((info (org-babel-get-src-block-info)))
|
||||
(should (string= "emacs-lisp" (nth 0 info))))))
|
||||
|
||||
(ert-deftest test-org-babel-get-src-block-info-body ()
|
||||
(org-test-at-marker nil test-org-code-block-anchor
|
||||
(org-test-at-marker nil org-test-file-ob-anchor
|
||||
(let ((info (org-babel-get-src-block-info)))
|
||||
(should (string-match (regexp-quote test-org-code-block-anchor)
|
||||
(should (string-match (regexp-quote org-test-file-ob-anchor)
|
||||
(nth 1 info))))))
|
||||
|
||||
(ert-deftest test-org-babel-get-src-block-info-tangle ()
|
||||
(org-test-at-marker nil test-org-code-block-anchor
|
||||
(org-test-at-marker nil org-test-file-ob-anchor
|
||||
(let ((info (org-babel-get-src-block-info)))
|
||||
(should (string= "no" (cdr (assoc :tangle (nth 2 info))))))))
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
;;; org-test-ob-consts.el --- constants for use in code block tests
|
||||
|
||||
;; 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:
|
||||
(defconst org-test-file-ob-anchor
|
||||
"94839181-184f-4ff4-a72f-94214df6f5ba")
|
||||
|
||||
(defconst org-test-link-in-heading-file-ob-anchor
|
||||
"a8b1d111-eca8-49f0-8930-56d4f0875155")
|
||||
|
||||
(provide 'org-test-ob-consts)
|
||||
|
||||
;;; org-test-ob-consts.el ends here
|
|
@ -62,15 +62,12 @@ org-test searches this directory up the directory tree.")
|
|||
(defconst org-test-file
|
||||
(expand-file-name "normal.org" org-test-example-dir))
|
||||
|
||||
(defconst org-test-no-header-file
|
||||
(expand-file-name "no-header.org" org-test-dir))
|
||||
(defconst org-test-no-heading-file
|
||||
(expand-file-name "no-heading.org" org-test-example-dir))
|
||||
|
||||
(defconst org-test-link-in-heading-file
|
||||
(expand-file-name "link-in-heading.org" org-test-dir))
|
||||
|
||||
(defconst test-org-code-block-anchor
|
||||
"94839181-184f-4ff4-a72f-94214df6f5ba")
|
||||
|
||||
|
||||
;;; Functions for writing tests
|
||||
|
||||
|
|
Loading…
Reference in New Issue