diff options
| author | Dmitry Gutov | 2019-12-29 15:44:08 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2019-12-29 15:46:44 +0300 |
| commit | 65af18d86eed140100c98c1bf3076f805f2bcc06 (patch) | |
| tree | 7cc2026b60ed7b848e0584c043fed0d101ccd1ba /test | |
| parent | 98788bf9768fec915c745aae8c9196636ffeaecc (diff) | |
| download | emacs-65af18d86eed140100c98c1bf3076f805f2bcc06.tar.gz emacs-65af18d86eed140100c98c1bf3076f805f2bcc06.zip | |
Rename xref-collect-references and xref-collect-matches
* lisp/progmodes/xref.el (xref-references-in-directory): Rename
from xref-collect-references. Update the sole caller.
(xref-matches-in-directory): Rename from xref-collect-matches.
Update all callers (all of them are in the /tests/ dir).
* test/lisp/progmodes/xref-tests.el (xref-tests-data-dir):
Don't use the EMACS_TEST_DIRECTORY env var. It doesn't work when
running interactively.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/xref-tests.el | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el index 31f455023f3..3fe3a658286 100644 --- a/test/lisp/progmodes/xref-tests.el +++ b/test/lisp/progmodes/xref-tests.el | |||
| @@ -27,14 +27,15 @@ | |||
| 27 | (require 'cl-lib) | 27 | (require 'cl-lib) |
| 28 | 28 | ||
| 29 | (defvar xref-tests-data-dir | 29 | (defvar xref-tests-data-dir |
| 30 | (expand-file-name "data/xref/" | 30 | (expand-file-name "../../../data/xref/" |
| 31 | (getenv "EMACS_TEST_DIRECTORY"))) | 31 | (or load-file-name |
| 32 | buffer-file-name))) | ||
| 32 | 33 | ||
| 33 | (ert-deftest xref-collect-matches-finds-none-for-some-regexp () | 34 | (ert-deftest xref-matches-in-directory-finds-none-for-some-regexp () |
| 34 | (should (null (xref-collect-matches "zzz" "*" xref-tests-data-dir nil)))) | 35 | (should (null (xref-matches-in-directory "zzz" "*" xref-tests-data-dir nil)))) |
| 35 | 36 | ||
| 36 | (ert-deftest xref-collect-matches-finds-some-for-bar () | 37 | (ert-deftest xref-matches-in-directory-finds-some-for-bar () |
| 37 | (let* ((matches (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | 38 | (let* ((matches (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil)) |
| 38 | (locs (cl-sort (mapcar #'xref-item-location matches) | 39 | (locs (cl-sort (mapcar #'xref-item-location matches) |
| 39 | #'string< | 40 | #'string< |
| 40 | :key #'xref-location-group))) | 41 | :key #'xref-location-group))) |
| @@ -42,8 +43,8 @@ | |||
| 42 | (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs)))) | 43 | (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 | (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs)))))) |
| 44 | 45 | ||
| 45 | (ert-deftest xref-collect-matches-finds-two-matches-on-the-same-line () | 46 | (ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line () |
| 46 | (let* ((matches (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) | 47 | (let* ((matches (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil)) |
| 47 | (locs (mapcar #'xref-item-location matches))) | 48 | (locs (mapcar #'xref-item-location matches))) |
| 48 | (should (= 2 (length matches))) | 49 | (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 0 locs)))) |
| @@ -53,8 +54,8 @@ | |||
| 53 | (should (equal 0 (xref-file-location-column (nth 0 locs)))) | 54 | (should (equal 0 (xref-file-location-column (nth 0 locs)))) |
| 54 | (should (equal 4 (xref-file-location-column (nth 1 locs)))))) | 55 | (should (equal 4 (xref-file-location-column (nth 1 locs)))))) |
| 55 | 56 | ||
| 56 | (ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match () | 57 | (ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match () |
| 57 | (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil)) | 58 | (let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil)) |
| 58 | (locs (mapcar #'xref-item-location matches))) | 59 | (locs (mapcar #'xref-item-location matches))) |
| 59 | (should (= 1 (length matches))) | 60 | (should (= 1 (length matches))) |
| 60 | (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs)))) | 61 | (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs)))) |
| @@ -62,7 +63,7 @@ | |||
| 62 | (should (equal 0 (xref-file-location-column (nth 0 locs)))))) | 63 | (should (equal 0 (xref-file-location-column (nth 0 locs)))))) |
| 63 | 64 | ||
| 64 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 () | 65 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 () |
| 65 | (let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil)) | 66 | (let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil)) |
| 66 | (iter (xref--buf-pairs-iterator xrefs)) | 67 | (iter (xref--buf-pairs-iterator xrefs)) |
| 67 | (cons (funcall iter :next))) | 68 | (cons (funcall iter :next))) |
| 68 | (should (null (funcall iter :next))) | 69 | (should (null (funcall iter :next))) |
| @@ -70,7 +71,7 @@ | |||
| 70 | (should (= 2 (length (cdr cons)))))) | 71 | (should (= 2 (length (cdr cons)))))) |
| 71 | 72 | ||
| 72 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 () | 73 | (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 () |
| 73 | (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | 74 | (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil)) |
| 74 | (iter (xref--buf-pairs-iterator xrefs)) | 75 | (iter (xref--buf-pairs-iterator xrefs)) |
| 75 | (cons1 (funcall iter :next)) | 76 | (cons1 (funcall iter :next)) |
| 76 | (cons2 (funcall iter :next))) | 77 | (cons2 (funcall iter :next))) |
| @@ -80,7 +81,7 @@ | |||
| 80 | (should (= 1 (length (cdr cons2)))))) | 81 | (should (= 1 (length (cdr cons2)))))) |
| 81 | 82 | ||
| 82 | (ert-deftest xref--buf-pairs-iterator-cleans-up-markers () | 83 | (ert-deftest xref--buf-pairs-iterator-cleans-up-markers () |
| 83 | (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil)) | 84 | (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil)) |
| 84 | (iter (xref--buf-pairs-iterator xrefs)) | 85 | (iter (xref--buf-pairs-iterator xrefs)) |
| 85 | (cons1 (funcall iter :next)) | 86 | (cons1 (funcall iter :next)) |
| 86 | (cons2 (funcall iter :next))) | 87 | (cons2 (funcall iter :next))) |