diff options
| author | Glenn Morris | 2013-06-25 18:52:09 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-06-25 18:52:09 -0700 |
| commit | f2136e1e28e9b3f0eb2aef6ebaf6be37024e7bb9 (patch) | |
| tree | f21176d2fe8c09f7d5da1e88dfb37d2abd60fafc /test | |
| parent | a343d218fd889e57ab80565815366734fb606b37 (diff) | |
| download | emacs-f2136e1e28e9b3f0eb2aef6ebaf6be37024e7bb9.tar.gz emacs-f2136e1e28e9b3f0eb2aef6ebaf6be37024e7bb9.zip | |
info-xref.el: Update for Texinfo 5 change in *note format
* lisp/info-xref.el (info-xref-node-re, info-xref-note-re): New constants.
(info-xref-check-buffer): Use info-xref-note-re.
* test/automated/info-xref.el: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/info-xref.el | 148 |
2 files changed, 152 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 4cacbf2766b..4aaa5f12bb7 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-06-26 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * automated/info-xref.el: New file. | ||
| 4 | |||
| 1 | 2013-06-25 Glenn Morris <rgm@gnu.org> | 5 | 2013-06-25 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * automated/occur-tests.el (occur-test-create): New function. | 7 | * automated/occur-tests.el (occur-test-create): New function. |
diff --git a/test/automated/info-xref.el b/test/automated/info-xref.el new file mode 100644 index 00000000000..973af0d46c7 --- /dev/null +++ b/test/automated/info-xref.el | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | ;;; info-xref.el --- tests for info-xref.el | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 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. | ||
| 11 | |||
| 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. | ||
| 16 | |||
| 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/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | (require 'info-xref) | ||
| 26 | |||
| 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) | ||
| 33 | (require 'info) | ||
| 34 | (let ((Info-directory-list '(".")) | ||
| 35 | Info-additional-directory-list) | ||
| 36 | (info-xref-with-output | ||
| 37 | (with-temp-buffer | ||
| 38 | (insert body) | ||
| 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)) | ||
| 43 | |||
| 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. | ||
| 48 | " '(0 0 1))) | ||
| 49 | |||
| 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. | ||
| 54 | " '(0 0 1))) | ||
| 55 | |||
| 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. | ||
| 60 | " '(0 0 1))) | ||
| 61 | |||
| 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." | ||
| 65 | (with-temp-buffer | ||
| 66 | (insert "\ | ||
| 67 | \input texinfo | ||
| 68 | @setfilename " | ||
| 69 | (format "%s.info\n" (file-name-sans-extension file)) | ||
| 70 | "\ | ||
| 71 | @settitle test | ||
| 72 | |||
| 73 | @ifnottex | ||
| 74 | @node Top | ||
| 75 | @top test | ||
| 76 | @end ifnottex | ||
| 77 | |||
| 78 | @menu | ||
| 79 | * Chapter One:: | ||
| 80 | @end menu | ||
| 81 | |||
| 82 | @node Chapter One | ||
| 83 | @chapter Chapter One | ||
| 84 | |||
| 85 | text. | ||
| 86 | |||
| 87 | " | ||
| 88 | body | ||
| 89 | "\ | ||
| 90 | @bye | ||
| 91 | " | ||
| 92 | ) | ||
| 93 | (write-region nil nil file nil 'silent)) | ||
| 94 | (should (equal 0 (call-process "makeinfo" file)))) | ||
| 95 | |||
| 96 | (ert-deftest info-xref-test-makeinfo () | ||
| 97 | "Test that info-xref can parse basic makeinfo output." | ||
| 98 | :expected-result (if (executable-find "makeinfo") :passed :failed) | ||
| 99 | (should (executable-find "makeinfo")) | ||
| 100 | (let ((tempfile (make-temp-file "info-xref-test" nil ".texi")) | ||
| 101 | (tempfile2 (make-temp-file "info-xref-test2" nil ".texi")) | ||
| 102 | (errflag t)) | ||
| 103 | (unwind-protect | ||
| 104 | (progn | ||
| 105 | ;; tempfile contains xrefs to various things, including tempfile2. | ||
| 106 | (info-xref-test-write-file | ||
| 107 | tempfile | ||
| 108 | (concat "\ | ||
| 109 | @xref{nodename,,,missing,Missing Manual}. | ||
| 110 | |||
| 111 | @xref{nodename,crossref,title,missing,Missing Manual}. | ||
| 112 | |||
| 113 | @xref{Chapter One}. | ||
| 114 | |||
| 115 | @xref{Chapter One,Something}. | ||
| 116 | |||
| 117 | " | ||
| 118 | (format "@xref{Chapter One,,,%s,Present Manual}.\n" | ||
| 119 | (file-name-sans-extension (file-name-nondirectory | ||
| 120 | tempfile2))))) | ||
| 121 | ;; Something for tempfile to xref to. | ||
| 122 | (info-xref-test-write-file tempfile2 "") | ||
| 123 | (require 'info) | ||
| 124 | (save-window-excursion | ||
| 125 | (let ((Info-directory-list | ||
| 126 | (list | ||
| 127 | (or (file-name-directory tempfile) "."))) | ||
| 128 | Info-additional-directory-list) | ||
| 129 | (info-xref-check (format "%s.info" (file-name-sans-extension | ||
| 130 | tempfile)))) | ||
| 131 | (should (equal (list info-xref-bad info-xref-good | ||
| 132 | info-xref-unavail) | ||
| 133 | '(0 1 2))) | ||
| 134 | (setq errflag nil) | ||
| 135 | ;; If there was an error, we can leave this around. | ||
| 136 | (kill-buffer info-xref-output-buffer))) | ||
| 137 | ;; Useful diagnostic in case of problems. | ||
| 138 | (if errflag | ||
| 139 | (with-temp-buffer | ||
| 140 | (call-process "makeinfo" nil t nil "--version") | ||
| 141 | (message "%s" (buffer-string)))) | ||
| 142 | (mapc 'delete-file (list tempfile tempfile2 | ||
| 143 | (format "%s.info" (file-name-sans-extension | ||
| 144 | tempfile)) | ||
| 145 | (format "%s.info" (file-name-sans-extension | ||
| 146 | tempfile2))))))) | ||
| 147 | |||
| 148 | ;;; info-xref.el ends here | ||