forked from fniessen/emacs-leuven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org-test-fni.el
78 lines (59 loc) · 2.61 KB
/
org-test-fni.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;;;; org-test-fni.el --- Extra tests for Org mode
;; Copyright (C) 2014-2016 Fabrice Niessen
;; Author: Fabrice Niessen
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Command:
;; emacs -Q --batch -L lisp/ -L testing/ -l ~/src/emacs-leuven/org-test-fni.el --eval '(setq org-confirm-babel-evaluate nil)' -f ert-run-tests-batch-and-exit
;;; Code:
;; Org mode (reverse order, so that the Org lisp directory will be found
;; before the Org contrib lisp directory).
(add-to-list 'load-path "~/Public/Repositories/org-mode/testing")
(add-to-list 'load-path "~/Public/Repositories/org-mode/contrib/lisp") ; htmlize
(add-to-list 'load-path "~/Public/Repositories/org-mode/lisp")
;; XXX This shoud be on the command-line!
(require 'ert)
(require 'ox)
;;; Functions for writing tests.
(defun compare-org-html-export-files (org-file)
"Compare current export of ORG-FILE with HTML file already present on disk."
(require 'ox-html)
(let* ((html-file (concat (file-name-directory org-file)
(file-name-base org-file) ".html"))
html-contents)
;; Should have a `.html' file.
(should
(file-exists-p html-file))
;; Should have the same `.html' exported file.
(should
(equal
;; New export.
(with-temp-buffer
(insert-file-contents org-file)
(setq html-contents
(let ((org-export-allow-bind-keywords t))
(org-export-as 'html)))
(delete-region (point-min) (point-max))
(insert html-contents)
(buffer-string))
;; Old export.
(with-temp-buffer
(insert-file-contents html-file)
(buffer-string))))))
;;; Internal tests.
(ert-deftest test-org-export/export-html-backend-test-file ()
"Compare current export of ORG-FILE with HTML file already present on disk."
(compare-org-html-export-files "~/src/emacs-leuven/org-test-sample.org"))
;; (ert 'test-org-export/export-html-backend-test-file)
(provide 'org-test-fni)
;;; org-test-fni.el ends here