aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-01 18:49:51 +0200
committerEli Zaretskii2016-12-01 18:49:51 +0200
commit2f68cb3e0502a9dc69613e97a5a5079ebf9249fb (patch)
tree2ac92f13aa0a418c91a95e2a52f071941cc76e80 /test
parent7d35b3d33da641b462d22df005266225e799d27f (diff)
downloademacs-2f68cb3e0502a9dc69613e97a5a5079ebf9249fb.tar.gz
emacs-2f68cb3e0502a9dc69613e97a5a5079ebf9249fb.zip
Fix bugs with buffer-local tags tables
* lisp/progmodes/etags.el (visit-tags-table): After 'visit-tags-table-buffer' returns, retrieve the value of 'tags-file-name' from the buffer we started in. Force recomputation of 'tags-completion-table' next time it is used, since the list of tags table has changed. (visit-tags-table-buffer): Accept an additional optional argument CBUF, the buffer in which to start processing, and switch to that buffer if CBUF is non-nil. All callers changed to supply a non-nil CBUF when they call 'visit-tags-table-buffer' in a loop. Doc fix. (tags-completion-table): Accept an optional argument, the buffer for which to build 'tags-completion-table', and build that buffer's completion table. (tags-lazy-completion-table): Pass the current buffer to 'tags-completion-table'. (tags-file-name): Don't say in the doc string that setting this variable directly is enough; say that 'visit-tags-table' should be used for that. (Bug#158) (Bug#17326) (Bug#23164) * doc/emacs/maintaining.texi (Select Tags Table): Delete the advice to set 'tags-file-name' directly. * test/lisp/progmodes/etags-tests.el: New tests.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/etags-tests.el83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/lisp/progmodes/etags-tests.el b/test/lisp/progmodes/etags-tests.el
new file mode 100644
index 00000000000..a715bba32ab
--- /dev/null
+++ b/test/lisp/progmodes/etags-tests.el
@@ -0,0 +1,83 @@
1;;; etags-tests.el --- Test suite for etags.el.
2
3;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5;; Author: Eli Zaretskii <eliz@gnu.org>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Code:
23
24(require 'ert)
25(require 'etags)
26
27(defvar his-masters-voice t)
28
29(defun y-or-n-p (_prompt)
30 "Replacement for `y-or-n-p' that returns what we tell it to."
31 his-masters-voice)
32
33(ert-deftest etags-bug-158 ()
34 "Test finding tags with local and global tags tables."
35 (let ((buf-with-global-tags (get-buffer-create "*buf-global*"))
36 (buf-with-local-tags (get-buffer-create "*buf-local*"))
37 xref-buf)
38 (set-buffer buf-with-global-tags)
39 (setq default-directory (expand-file-name "."))
40 (visit-tags-table "./manual/etags/ETAGS.good_1")
41 ;; Check that tags in ETAGS.good_1 are recognized.
42 (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
43 (should (bufferp xref-buf))
44 (kill-buffer xref-buf)
45 (setq xref-buf (xref-find-definitions "PrintAdd"))
46 (should (bufferp xref-buf))
47 (kill-buffer xref-buf)
48 ;; Check that tags not in ETAGS.good_1, but in ETAGS.good_3, are
49 ;; NOT recognized.
50 (should-error (xref-find-definitions "intNumber") :type 'user-error)
51 (kill-buffer xref-buf)
52 (set-buffer buf-with-local-tags)
53 (setq default-directory (expand-file-name "."))
54 (let (his-masters-voice)
55 (visit-tags-table "./manual/etags/ETAGS.good_3" t))
56 ;; Check that tags in ETAGS.good_1 are recognized.
57 (setq xref-buf (xref-find-definitions "LL_Task_Procedure_Access/t"))
58 (should (bufferp xref-buf))
59 (kill-buffer xref-buf)
60 (setq xref-buf (xref-find-definitions "PrintAdd"))
61 (should (bufferp xref-buf))
62 (kill-buffer xref-buf)
63 ;; Check that tags in ETAGS.good_3 are recognized. This is a test
64 ;; for bug#158.
65 (setq xref-buf (xref-find-definitions "intNumber"))
66 (should (or (null xref-buf)
67 (bufferp xref-buf)))
68 ;; Bug #17326
69 (should (string= (file-name-nondirectory
70 (buffer-local-value 'tags-file-name buf-with-local-tags))
71 "ETAGS.good_3"))
72 (should (string= (file-name-nondirectory
73 (default-value 'tags-file-name))
74 "ETAGS.good_1"))
75 (if (bufferp xref-buf) (kill-buffer xref-buf))))
76
77(ert-deftest etags-bug-23164 ()
78 "Test that setting a local value of tags table doesn't signal errors."
79 (set-buffer (get-buffer-create "*foobar*"))
80 (fundamental-mode)
81 (visit-tags-table "./manual/etags/ETAGS.good_3" t)
82 (should (equal (should-error (xref-find-definitions "foobar123"))
83 '(user-error "No definitions found for: foobar123"))))