summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-10-04 20:07:51 -0600
committerEric Schulte <schulte.eric@gmail.com>2010-10-05 11:54:48 -0600
commite1b90eea45aa8ea366d82feb4dbd8e4219207557 (patch)
tree18929e66fb6028079ff72f0df3b7ff5eb3cde9a7
parent41cde9d9bd7ce6510636b70447545dc0ebb0cbc9 (diff)
downloadorg-mode-e1b90eea45aa8ea366d82feb4dbd8e4219207557.tar.gz
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
-rw-r--r--lisp/ob-exp.el6
-rw-r--r--testing/examples/no-heading.org (renamed from testing/examples/example-file-no-header.org)0
-rw-r--r--testing/lisp/test-ob-exp.el34
-rw-r--r--testing/lisp/test-ob.el9
-rw-r--r--testing/org-test-ob-consts.el23
-rw-r--r--testing/org-test.el7
6 files changed, 61 insertions, 18 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 3b5410d..3004c4a 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -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
diff --git a/testing/examples/example-file-no-header.org b/testing/examples/no-heading.org
index 24d7c08..24d7c08 100644
--- a/testing/examples/example-file-no-header.org
+++ b/testing/examples/no-heading.org
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index b0b562b..cc87477 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -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
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index d433692..b28753e 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -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))))))))
diff --git a/testing/org-test-ob-consts.el b/testing/org-test-ob-consts.el
new file mode 100644
index 0000000..75b4e3b
--- /dev/null
+++ b/testing/org-test-ob-consts.el
@@ -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 \ No newline at end of file
diff --git a/testing/org-test.el b/testing/org-test.el
index 82d9542..5248952 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -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