Manually revert maint to e85080.
[org-mode.git] / testing / lisp / test-ob-exp.el
blob8899e0d51b68e794b591dbfd4844e91391d3c112
1 ;;; test-ob-exp.el
3 ;; Copyright (c) 2010 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
9 ;;;; Comments:
11 ;; Template test file for Org-mode tests
14 ;;; Code:
15 (let ((load-path (cons (expand-file-name
16 ".." (file-name-directory
17 (or load-file-name buffer-file-name)))
18 load-path)))
19 (require 'org-test)
20 (require 'org-test-ob-consts))
23 ;;; Tests
24 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers ()
25 "Testing export without any headlines in the org-mode file."
26 (let ((html-file (concat (file-name-sans-extension org-test-no-heading-file)
27 ".html")))
28 (when (file-exists-p html-file) (delete-file html-file))
29 (org-test-in-example-file org-test-no-heading-file
30 ;; export the file to html
31 (org-export-as-html nil))
32 ;; should create a .html file
33 (should (file-exists-p html-file))
34 ;; should not create a file with "::" appended to it's name
35 (should-not (file-exists-p (concat org-test-no-heading-file "::")))
36 (when (file-exists-p html-file) (delete-file html-file))))
38 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-file ()
39 "Testing export from buffers which are not visiting any file."
40 (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*"))
41 (should-not (get-buffer "*Org HTML Export*"))
42 ;; export the file to HTML in a temporary buffer
43 (org-test-in-example-file nil (org-export-as-html-to-buffer nil))
44 ;; should create a .html buffer
45 (should (buffer-live-p (get-buffer "*Org HTML Export*")))
46 ;; should contain the content of the buffer
47 (save-excursion
48 (set-buffer (get-buffer "*Org HTML Export*"))
49 (should (string-match (regexp-quote org-test-file-ob-anchor)
50 (buffer-string))))
51 (when (get-buffer "*Org HTML Export*") (kill-buffer "*Org HTML Export*")))
53 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers2 ()
54 "Testing export without any headlines in the org-mode file."
55 (let ((html-file (concat (file-name-sans-extension
56 org-test-link-in-heading-file)
57 ".html")))
58 (when (file-exists-p html-file) (delete-file html-file))
59 (org-test-in-example-file org-test-link-in-heading-file
60 ;; export the file to html
61 (org-export-as-html nil))
62 ;; should create a .html file
63 (should (file-exists-p html-file))
64 ;; should not create a file with "::" appended to it's name
65 (should-not (file-exists-p (concat org-test-link-in-heading-file "::")))
66 (when (file-exists-p html-file) (delete-file html-file))))
68 ;; TODO
69 ;; (ert-deftest ob-exp/noweb-on-export ()
70 ;; "Noweb header arguments export correctly.
71 ;; - yes expand on both export and tangle
72 ;; - no expand on neither export or tangle
73 ;; - tangle expand on only tangle not export"
74 ;; (let (html)
75 ;; (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
76 ;; (org-narrow-to-subtree)
77 ;; (let ((arg nil)
78 ;; )
79 ;; (mapcar (lambda (x)
80 ;; (should (equal ""
81 ;; (org-export-as-html nil
82 ;; nil
83 ;; nil
84 ;; 'string))))
85 ;; '("yes" "no" "tangle"))))))
88 ;; TODO Test broken (args-out-of-range 1927 3462)
89 ;; (ert-deftest ob-exp/exports-both ()
90 ;; "Test the :exports both header argument.
91 ;; The code block should create both <pre></pre> and <table></table>
92 ;; elements in the final html."
93 ;; (let (html)
94 ;; (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
95 ;; (org-narrow-to-subtree)
96 ;; (setq html (org-export-as-html nil nil nil 'string))
97 ;; (should (string-match "<pre.*>[^\000]*</pre>" html))
98 ;; (should (string-match "<table.*>[^\000]*</table>" html)))))
100 ;; TODO Test Broken - causes ert to go off into the weeds
101 ;; (ert-deftest ob-exp/export-subtree ()
102 ;; (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
103 ;; (org-mark-subtree)
104 ;; (org-export-as-latex nil)))
106 (ert-deftest ob-exp/evaluate-all-executables-in-order ()
107 (org-test-at-id "96cc7073-97ec-4556-87cf-1f9bffafd317"
108 (org-narrow-to-subtree)
109 (let (*evaluation-collector*)
110 (org-export-as-ascii nil nil nil 'string)
111 (should (equal '(5 4 3 2 1) *evaluation-collector*)))))
113 (provide 'test-ob-exp)
115 ;;; test-ob-exp.el ends here