emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 05adcef 1/2: Xref test improvements


From: Dmitry Gutov
Subject: master 05adcef 1/2: Xref test improvements
Date: Sun, 7 Mar 2021 21:31:51 -0500 (EST)

branch: master
commit 05adcefa1f615a6e944322755ce35b75c0dfe24d
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Xref test improvements
    
    * 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 | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/test/lisp/progmodes/xref-tests.el 
b/test/lisp/progmodes/xref-tests.el
index b4b5e4d..028c43d 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -69,6 +69,15 @@
     (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))
@@ -99,18 +108,18 @@
     (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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]