]> git.eshelyaron.com Git - emacs.git/commitdiff
Xref test improvements
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 8 Mar 2021 00:44:24 +0000 (02:44 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 8 Mar 2021 00:44:24 +0000 (02:44 +0200)
* test/lisp/progmodes/xref-tests.el
(xref--xref-file-name-display-is-abs):
Fix not to rely on the default value.
(xref-matches-in-files-includes-matches-from-all-the-files):
New test.

test/lisp/progmodes/xref-tests.el

index b4b5e4db5d60887b7b0ed7120d74edbaec804f03..028c43db43e7e5541282c55704809ed4d8310262 100644 (file)
     (should (equal 1 (xref-location-line (nth 0 locs))))
     (should (equal 0 (xref-location-column (nth 0 locs))))))
 
+(ert-deftest xref-matches-in-files-includes-matches-from-all-the-files ()
+  (let ((matches (xref-matches-in-files "bar"
+                                        (directory-files xref-tests--data-dir t
+                                                         "\\`[^.]"))))
+    (should (= 2 (length matches)))
+    (should (cl-every
+             (lambda (match) (equal (xref-item-summary match) "bar"))
+             matches))))
+
 (ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
   (let* ((xrefs (xref-tests--matches-in-data-dir "foo"))
          (iter (xref--buf-pairs-iterator xrefs))
     (should (null (marker-position (cdr (nth 0 (cdr cons2))))))))
 
 (ert-deftest xref--xref-file-name-display-is-abs ()
-  (let ((xref-file-name-display 'abs)
-        ;; Some older BSD find versions can produce '//' in the output.
-        (expected (list
-                   (concat xref-tests--data-dir "/?file1.txt")
-                   (concat xref-tests--data-dir "/?file2.txt")))
-        (actual (delete-dups
-                 (mapcar 'xref-location-group
-                         (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))))
-    (should (and (= (length expected) (length actual))
-                 (cl-every (lambda (e1 e2)
-                             (string-match-p e1 e2))
-                           expected actual)))))
+  (let* ((xref-file-name-display 'abs)
+         ;; Some older BSD find versions can produce '//' in the output.
+         (expected (list
+                    (concat xref-tests--data-dir "/?file1.txt")
+                    (concat xref-tests--data-dir "/?file2.txt")))
+         (actual (delete-dups
+                  (mapcar 'xref-location-group
+                          (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)")))))
+    (should (= (length expected) (length actual)))
+    (should (cl-every (lambda (e1 e2)
+                        (string-match-p e1 e2))
+                      expected actual))))
 
 (ert-deftest xref--xref-file-name-display-is-nondirectory ()
   (let ((xref-file-name-display 'nondirectory))