From 331e40a8fd491ceb35c08a3345785dab61bc60d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=ADn?= Date: Wed, 6 Jan 2021 22:53:40 +0200 Subject: [PATCH] Fix some failing tests in BSD systems * test/lisp/progmodes/xref-tests.el (xref--xref-file-name-display-is-abs) (xref--xref-file-name-display-is-relative-to-project-root): Accommodate some older versions of BSD find (https://lists.gnu.org/archive/html/emacs-devel/2021-01/msg00156.html). --- test/lisp/progmodes/xref-tests.el | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el index eaafc5888c7..b4b5e4db5d6 100644 --- a/test/lisp/progmodes/xref-tests.el +++ b/test/lisp/progmodes/xref-tests.el @@ -99,13 +99,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)) - (should (equal (delete-dups - (mapcar 'xref-location-group - (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)"))) - (list - (concat xref-tests--data-dir "file1.txt") - (concat xref-tests--data-dir "file2.txt")))))) + (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))))) (ert-deftest xref--xref-file-name-display-is-nondirectory () (let ((xref-file-name-display 'nondirectory)) @@ -121,10 +126,15 @@ (file-name-directory (directory-file-name xref-tests--data-dir))) (project-find-functions #'(lambda (_) (cons 'transient data-parent-dir))) - (xref-file-name-display 'project-relative)) - (should (equal (delete-dups - (mapcar 'xref-location-group - (xref-tests--locations-in-data-dir "\\(bar\\|foo\\)"))) - (list - "xref-resources/file1.txt" - "xref-resources/file2.txt"))))) + (xref-file-name-display 'project-relative) + ;; Some older BSD find versions can produce '//' in the output. + (expected (list + "xref-resources//?file1.txt" + "xref-resources//?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))))) -- 2.39.5