diff options
| author | Paul Eggert | 2016-05-06 10:09:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-05-06 10:09:53 -0700 |
| commit | 81204b276f849b577a0ccd0b6175353dfa9e2a07 (patch) | |
| tree | 0b3c205165739eafbaa5f315caf9f16fe03800aa /test/automated | |
| parent | 89ce83b20249dfb4e45f09dfdddf4c4b66d82968 (diff) | |
| download | emacs-81204b276f849b577a0ccd0b6175353dfa9e2a07.tar.gz emacs-81204b276f849b577a0ccd0b6175353dfa9e2a07.zip | |
Port xref-tests to master branch
Also, add a test to make this problem less likely in the future.
* test/Makefile.in (check-no-automated-subdir): New rule.
(check, check-expensive, check-maybe): Depend on it.
* test/automated/data/xref/file1.txt: Rename to ...
* test/data/xref/file1.txt: ... here.
* test/automated/data/xref/file2.txt: Rename to ...
* test/data/xref/file2.txt: ... here.
* test/automated/xref-tests.el: Rename to ...
* test/lisp/progmodes/xref-tests.el: ... here.
(xref-tests-data-dir): Use EMACS_TEST_DIRECTORY.
Diffstat (limited to 'test/automated')
| -rw-r--r-- | test/automated/data/xref/file1.txt | 2 | ||||
| -rw-r--r-- | test/automated/data/xref/file2.txt | 2 | ||||
| -rw-r--r-- | test/automated/xref-tests.el | 91 |
3 files changed, 0 insertions, 95 deletions
diff --git a/test/automated/data/xref/file1.txt b/test/automated/data/xref/file1.txt deleted file mode 100644 index 5d7cc544443..00000000000 --- a/test/automated/data/xref/file1.txt +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | foo foo | ||
| 2 | bar | ||
diff --git a/test/automated/data/xref/file2.txt b/test/automated/data/xref/file2.txt deleted file mode 100644 index 9f075f26004..00000000000 --- a/test/automated/data/xref/file2.txt +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | |||
| 2 | bar | ||
diff --git a/test/automated/xref-tests.el b/test/automated/xref-tests.el deleted file mode 100644 index 079b196aa8b..00000000000 --- a/test/automated/xref-tests.el +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 1 | ;;; xref-tests.el --- tests for xref | ||
| 2 | |||
| 3 | ;; Copyright (C) 2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Dmitry Gutov <dgutov@yandex.ru> | ||
| 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 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (require 'xref) | ||
| 27 | (require 'cl-lib) | ||
| 28 | |||
| 29 | (defvar xref-tests-data-dir | ||
| 30 | (expand-file-name "data/xref/" | ||
| 31 | (file-name-directory (or load-file-name (buffer-file-name))))) | ||
| 32 | |||
| 33 | (ert-deftest xref-collect-matches-finds-none-for-some-regexp () | ||
| 34 | (should (null (xref-collect-matches "zzz" "*" xref-tests-data-dir nil)))) | ||
| 35 | |||
| 36 | (ert-deftest xref-collect-matches-finds-some-for-bar () | ||
| 37 | (let* ((matches (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | ||
| 38 | (locs (cl-sort (mapcar #'xref-item-location matches) | ||
| 39 | #'string< | ||
| 40 | :key #'xref-location-group))) | ||
| 41 | (should (= 2 (length matches))) | ||
| 42 | (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs)))) | ||
| 43 | (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs)))))) | ||
| 44 | |||
| 45 | (ert-deftest xref-collect-matches-finds-two-matches-on-the-same-line () | ||
| 46 | (let* ((matches (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) | ||
| 47 | (locs (mapcar #'xref-item-location matches))) | ||
| 48 | (should (= 2 (length matches))) | ||
| 49 | (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs)))) | ||
| 50 | (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs)))) | ||
| 51 | (should (equal 1 (xref-location-line (nth 0 locs)))) | ||
| 52 | (should (equal 1 (xref-location-line (nth 1 locs)))) | ||
| 53 | (should (equal 0 (xref-file-location-column (nth 0 locs)))) | ||
| 54 | (should (equal 4 (xref-file-location-column (nth 1 locs)))))) | ||
| 55 | |||
| 56 | (ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match () | ||
| 57 | (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil)) | ||
| 58 | (locs (mapcar #'xref-item-location matches))) | ||
| 59 | (should (= 1 (length matches))) | ||
| 60 | (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs)))) | ||
| 61 | (should (equal 1 (xref-location-line (nth 0 locs)))) | ||
| 62 | (should (equal 0 (xref-file-location-column (nth 0 locs)))))) | ||
| 63 | |||
| 64 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 () | ||
| 65 | (let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) | ||
| 66 | (iter (xref--buf-pairs-iterator xrefs)) | ||
| 67 | (cons (funcall iter :next))) | ||
| 68 | (should (null (funcall iter :next))) | ||
| 69 | (should (string-match "file1\\.txt\\'" (buffer-file-name (car cons)))) | ||
| 70 | (should (= 2 (length (cdr cons)))))) | ||
| 71 | |||
| 72 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 () | ||
| 73 | (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | ||
| 74 | (iter (xref--buf-pairs-iterator xrefs)) | ||
| 75 | (cons1 (funcall iter :next)) | ||
| 76 | (cons2 (funcall iter :next))) | ||
| 77 | (should (null (funcall iter :next))) | ||
| 78 | (should-not (equal (car cons1) (car cons2))) | ||
| 79 | (should (= 1 (length (cdr cons1)))) | ||
| 80 | (should (= 1 (length (cdr cons2)))))) | ||
| 81 | |||
| 82 | (ert-deftest xref--buf-pairs-iterator-cleans-up-markers () | ||
| 83 | (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | ||
| 84 | (iter (xref--buf-pairs-iterator xrefs)) | ||
| 85 | (cons1 (funcall iter :next)) | ||
| 86 | (cons2 (funcall iter :next))) | ||
| 87 | (funcall iter :cleanup) | ||
| 88 | (should (null (marker-position (car (nth 0 (cdr cons1)))))) | ||
| 89 | (should (null (marker-position (cdr (nth 0 (cdr cons1)))))) | ||
| 90 | (should (null (marker-position (car (nth 0 (cdr cons2)))))) | ||
| 91 | (should (null (marker-position (cdr (nth 0 (cdr cons2)))))))) | ||