diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2021-09-06 05:01:07 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2021-09-06 05:01:07 +0300 |
commit | 71f8b55f46af307759fb30dcf3f784092dd8834d (patch) | |
tree | 64296711c7c120134fda17900a71cc5c3a4cd500 /test/lisp | |
parent | 80d318aabbbf34761260104a0ddebde1ace559a6 (diff) | |
download | emacs-71f8b55f46af307759fb30dcf3f784092dd8834d.tar.gz emacs-71f8b55f46af307759fb30dcf3f784092dd8834d.tar.bz2 emacs-71f8b55f46af307759fb30dcf3f784092dd8834d.zip |
project--files-in-directory: Fix handling of ignores
* lisp/progmodes/project.el (project--files-in-directory):
Pass "." as the DIR argument to 'find' because otherwise the ignore
expression can match the project root directory name, which we don't
want to happen (bug#50240). Fixup the resulting file names at the end
with concatenation.
Originally I thought it could lead to worse performance, but the
results show equal or slightly better timings.
* lisp/progmodes/xref.el (xref-matches-in-directory):
Apply a similar fix.
(xref--find-ignores-arguments): Use file-name-as-directory, so
that when passed "." replace-match still had the expected effect.
* test/lisp/progmodes/project-tests.el (project-ignores-bug-50240):
New test.
* test/lisp/progmodes/xref-tests.el
(xref-matches-in-directory-filters-with-ignores): New test.
Diffstat (limited to 'test/lisp')
-rw-r--r-- | test/lisp/progmodes/project-tests.el | 15 | ||||
-rw-r--r-- | test/lisp/progmodes/xref-tests.el | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/lisp/progmodes/project-tests.el b/test/lisp/progmodes/project-tests.el index 68460a9fa5b..1e3f258ac2a 100644 --- a/test/lisp/progmodes/project-tests.el +++ b/test/lisp/progmodes/project-tests.el @@ -107,4 +107,19 @@ directory name (Bug#48471)." collect (file-relative-name file dir)))) (should (equal relative-files '("some-file")))))) +(ert-deftest project-ignores-bug-50240 () + "Check that `project-files' does not ignore all files. +When `project-ignores' includes a name matching project dir." + (skip-unless (executable-find find-program)) + (project-tests--with-temporary-directory dir + (make-empty-file (expand-file-name "some-file" dir)) + (let* ((project (make-project-tests--trivial + :root (file-name-as-directory dir) + :ignores (list (file-name-nondirectory + (directory-file-name dir))))) + (files (project-files project))) + (should (equal files + (list + (expand-file-name "some-file" dir))))))) + ;;; project-tests.el ends here diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el index d29452243b2..ff4b647ae0f 100644 --- a/test/lisp/progmodes/xref-tests.el +++ b/test/lisp/progmodes/xref-tests.el @@ -52,6 +52,14 @@ (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-matches-in-directory-filters-with-ignores () + (let ((locs (xref-matches-in-directory "bar" "*" xref-tests--data-dir + '("./file1.*")))) + (should (= 1 (length locs))) + (should (string-match-p "file2\\.txt\\'" (xref-location-group + (xref-item-location + (nth 0 locs))))))) + (ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line () (let ((locs (xref-tests--locations-in-data-dir "foo"))) (should (= 2 (length locs))) |