aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
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"))))