1 (add-to-list 'load-path
(expand-file-name "tools"))
4 (defun org-export-as-html-test-fixture (file body
)
5 "Export the example.org buffer to html, then run the tests in
6 body passing in the org-buffer and the html-buffer as arguments"
8 (let* ((org-buffer (save-excursion (find-file file
)
10 (html-buffer "*Org HTML Export*"))
12 (set-buffer org-buffer
)
13 (call-interactively 'org-export-as-html-to-buffer
)
16 (eval (list body org-buffer html-buffer
))))
19 (kill-buffer "*Org HTML Export*")
22 (defun org-test-search-map-all-org-html-links (buffer body
)
23 "for each org link in BUFFER call BODY passing the link-url and
24 link-text as arguments."
27 (goto-char (point-min))
28 (while (re-search-forward "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" nil t
)
29 (eval (list body
(match-string 1) (replace-regexp-in-string "[\r\n]" " " (match-string 3)))))))
31 ;; this actually defines the test to be run by ert
32 (ert-deftest org-test-export-as-html
()
33 (org-export-as-html-test-fixture
35 (lambda (org-buffer html-buffer
)
36 (org-test-search-map-all-org-html-links
38 (lambda (link-url link-text
)
40 (message (format "%s as %s" link-url link-text
))
41 (set-buffer html-buffer
)
42 (goto-char (point-min))
43 (search-forward link-text
)
44 (re-search-backward "<a href=\"\\(.*\\)\"" nil t
)
45 (should (string= (match-string 1)
48 ;; this runs the ert test
49 (ert-run-tests-interactively "^org-test-export-" " *org export tests*")