From: "Daniel Martín" <mardani29@yahoo.es>
To: emacs-devel@gnu.org
Subject: [PATCH] Fix some failing tests in BSD systems
Date: Sun, 03 Jan 2021 18:16:46 +0100 [thread overview]
Message-ID: <m1sg7i7xfl.fsf@yahoo.es> (raw)
In-Reply-To: m1sg7i7xfl.fsf.ref@yahoo.es
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
A couple of tests are failing for me on master and a BSD system (macOS):
2 unexpected results:
FAILED xref--xref-file-name-display-is-abs
FAILED xref--xref-file-name-display-is-relative-to-project-root
An extract of a test failure is
(list-elt 0 (arrays-of-different-length 25 24
"xref-resources//file1.txt" "xref-resources/file1.txt" first-mismatch-at
15))
The reason for the failure is that BSD 'find' sometimes outputs paths
with an extra '/', for example:
find /path/emacs/test/lisp/progmodes/xref-resources/ -type f \( -iname \* \)
/path/emacs/test/lisp/progmodes/xref-resources//file2.txt
/path/emacs/test/lisp/progmodes/xref-resources//file1.txt
(Note the trailing '/' in the first argument to 'find'.)
As I think this differs from GNU find but it's still a valid POSIX path,
I decided to make the tests more flexible.
Could you install the attached patch if you think it does TRT?
Thanks.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-some-xref-tests-for-systems-with-BSD-find.patch --]
[-- Type: text/x-patch, Size: 3288 bytes --]
From 6c82722c7ecba28fce619fa4b4fcb3d4425ffa64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 3 Jan 2021 18:13:07 +0100
Subject: [PATCH] Fix some xref-tests for systems with BSD find
Some versions of BSD find, like those present on macOS systems, may
return a file path with two intermediate
slashes (eg. "path/to//resource"). As this is valid POSIX, just make
the tests more flexible to accommodate for this situation.
---
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 eaafc5888c..dd083d655b 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -99,13 +99,18 @@ xref--buf-pairs-iterator-cleans-up-markers
(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)
+ ;; BSD find may add an extra '/' to the path.
+ (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 @@ xref--xref-file-name-display-is-relative-to-project-root
(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)
+ ;; BSD find may add an extra '/' to the path.
+ (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.28.0
next parent reply other threads:[~2021-01-03 17:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m1sg7i7xfl.fsf.ref@yahoo.es>
2021-01-03 17:16 ` Daniel Martín [this message]
2021-01-03 17:35 ` [PATCH] Fix some failing tests in BSD systems Eli Zaretskii
2021-01-03 21:08 ` Daniel Martín
2021-01-04 1:41 ` Dmitry Gutov
2021-01-04 3:30 ` Eli Zaretskii
2021-01-04 13:10 ` Dmitry Gutov
2021-01-04 15:52 ` Eli Zaretskii
2021-01-04 17:10 ` Dmitry Gutov
2021-01-04 22:25 ` Daniel Martín
2021-01-06 1:38 ` Dmitry Gutov
2021-01-06 9:41 ` Daniel Martín
2021-01-06 17:17 ` Dmitry Gutov
2021-01-06 18:48 ` Stefan Monnier
2021-01-06 21:17 ` Dmitry Gutov
2021-01-04 1:43 ` Dmitry Gutov
2021-01-04 3:48 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1sg7i7xfl.fsf@yahoo.es \
--to=mardani29@yahoo.es \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.