summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/xref-tests.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2019-12-29 15:44:08 +0300
committerDmitry Gutov <dgutov@yandex.ru>2019-12-29 15:46:44 +0300
commit65af18d86eed140100c98c1bf3076f805f2bcc06 (patch)
tree7cc2026b60ed7b848e0584c043fed0d101ccd1ba /test/lisp/progmodes/xref-tests.el
parent98788bf9768fec915c745aae8c9196636ffeaecc (diff)
downloademacs-65af18d86eed140100c98c1bf3076f805f2bcc06.tar.gz
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/lisp/progmodes/xref-tests.el')
-rw-r--r--test/lisp/progmodes/xref-tests.el27
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 @@
(require 'cl-lib)
(defvar xref-tests-data-dir
- (expand-file-name "data/xref/"
- (getenv "EMACS_TEST_DIRECTORY")))
+ (expand-file-name "../../../data/xref/"
+ (or load-file-name
+ buffer-file-name)))
-(ert-deftest xref-collect-matches-finds-none-for-some-regexp ()
- (should (null (xref-collect-matches "zzz" "*" xref-tests-data-dir nil))))
+(ert-deftest xref-matches-in-directory-finds-none-for-some-regexp ()
+ (should (null (xref-matches-in-directory "zzz" "*" xref-tests-data-dir nil))))
-(ert-deftest xref-collect-matches-finds-some-for-bar ()
- (let* ((matches (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
+(ert-deftest xref-matches-in-directory-finds-some-for-bar ()
+ (let* ((matches (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
(locs (cl-sort (mapcar #'xref-item-location matches)
#'string<
:key #'xref-location-group)))
@@ -42,8 +43,8 @@
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs))))))
-(ert-deftest xref-collect-matches-finds-two-matches-on-the-same-line ()
- (let* ((matches (xref-collect-matches "foo" "*" xref-tests-data-dir nil))
+(ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line ()
+ (let* ((matches (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
(locs (mapcar #'xref-item-location matches)))
(should (= 2 (length matches)))
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
@@ -53,8 +54,8 @@
(should (equal 0 (xref-file-location-column (nth 0 locs))))
(should (equal 4 (xref-file-location-column (nth 1 locs))))))
-(ert-deftest xref-collect-matches-finds-an-empty-line-regexp-match ()
- (let* ((matches (xref-collect-matches "^$" "*" xref-tests-data-dir nil))
+(ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match ()
+ (let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil))
(locs (mapcar #'xref-item-location matches)))
(should (= 1 (length matches)))
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
@@ -62,7 +63,7 @@
(should (equal 0 (xref-file-location-column (nth 0 locs))))))
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
- (let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil))
+ (let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
(iter (xref--buf-pairs-iterator xrefs))
(cons (funcall iter :next)))
(should (null (funcall iter :next)))
@@ -70,7 +71,7 @@
(should (= 2 (length (cdr cons))))))
(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 ()
- (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
+ (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
(iter (xref--buf-pairs-iterator xrefs))
(cons1 (funcall iter :next))
(cons2 (funcall iter :next)))
@@ -80,7 +81,7 @@
(should (= 1 (length (cdr cons2))))))
(ert-deftest xref--buf-pairs-iterator-cleans-up-markers ()
- (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
+ (let* ((xrefs (xref-matches-in-directory "bar" "*" xref-tests-data-dir nil))
(iter (xref--buf-pairs-iterator xrefs))
(cons1 (funcall iter :next))
(cons2 (funcall iter :next)))