1 ;;; info-xref.el --- tests for info-xref.el
3 ;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (defun info-xref-test-internal (body result
)
28 "Body of a basic info-xref ert test.
29 BODY is a string from an info buffer.
30 RESULT is a list (NBAD NGOOD NUNAVAIL)."
31 (get-buffer-create info-xref-output-buffer
)
32 (setq info-xref-xfile-alist nil
)
34 (let ((Info-directory-list '("."))
35 Info-additional-directory-list
)
36 (info-xref-with-output
39 (info-xref-check-buffer))))
40 (should (equal result
(list info-xref-bad info-xref-good info-xref-unavail
)))
41 ;; If there was an error, we can leave this around.
42 (kill-buffer info-xref-output-buffer
))
44 (ert-deftest info-xref-test-node-crossref
()
45 "Test parsing of @xref{node,crossref,,manual} with Texinfo 4/5."
46 (info-xref-test-internal "
47 *Note crossref: (manual-foo)node. Texinfo 4/5 format with crossref.
50 (ert-deftest info-xref-test-node-4
()
51 "Test parsing of @xref{node,,,manual} with Texinfo 4."
52 (info-xref-test-internal "
53 *Note node: (manual-foo)node. Texinfo 4 format with no crossref.
56 (ert-deftest info-xref-test-node-5
()
57 "Test parsing of @xref{node,,,manual} with Texinfo 5."
58 (info-xref-test-internal "
59 *Note (manual-foo)node::. Texinfo 5 format with no crossref.
62 ;; TODO Easier to have static data files in the repo?
63 (defun info-xref-test-write-file (file body
)
64 "Write BODY to texi FILE."
69 (format "%s.info\n" (file-name-sans-extension file
))
93 (write-region nil nil file nil
'silent
))
94 (should (equal 0 (call-process "makeinfo" file
))))
96 (ert-deftest info-xref-test-makeinfo
()
97 "Test that info-xref can parse basic makeinfo output."
98 (skip-unless (executable-find "makeinfo"))
99 (let ((tempfile (make-temp-file "info-xref-test" nil
".texi"))
100 (tempfile2 (make-temp-file "info-xref-test2" nil
".texi"))
104 ;; tempfile contains xrefs to various things, including tempfile2.
105 (info-xref-test-write-file
108 @xref{nodename,,,missing,Missing Manual}.
110 @xref{nodename,crossref,title,missing,Missing Manual}.
114 @xref{Chapter One,Something}.
117 (format "@xref{Chapter One,,,%s,Present Manual}.\n"
118 (file-name-sans-extension (file-name-nondirectory
120 ;; Something for tempfile to xref to.
121 (info-xref-test-write-file tempfile2
"")
123 (save-window-excursion
124 (let ((Info-directory-list
126 (or (file-name-directory tempfile
) ".")))
127 Info-additional-directory-list
)
128 (info-xref-check (format "%s.info" (file-name-sans-extension
130 (should (equal (list info-xref-bad info-xref-good
134 ;; If there was an error, we can leave this around.
135 (kill-buffer info-xref-output-buffer
)))
136 ;; Useful diagnostic in case of problems.
139 (call-process "makeinfo" nil t nil
"--version")
140 (message "%s" (buffer-string))))
141 (mapc 'delete-file
(list tempfile tempfile2
142 (format "%s.info" (file-name-sans-extension
144 (format "%s.info" (file-name-sans-extension
147 ;;; info-xref.el ends here