Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

### Bugs fixed

- [#2191](https://github.com/bbatsov/projectile/pull/2191): The test suite passes under native compilation with an empty eln cache, as in distro package builds, instead of failing two dirconfig specs with `native-lisp-load-failed` ([#2100](https://github.com/bbatsov/projectile/issues/2100)).
- [#2190](https://github.com/bbatsov/projectile/pull/2190): Alien indexing no longer hands git exclude pathspecs to an `fd` whose `projectile-git-fd-args` lacks `--strip-cwd-prefix`, which made it fail with `No valid search paths given` ([#2187](https://github.com/bbatsov/projectile/issues/2187)).
- [#2183](https://github.com/bbatsov/projectile/pull/2183): `projectile-run-test-at-point` now builds a usable file path when the project is reached through a symlink (anything under `/tmp` on macOS, or a symlinked `~/src`), instead of one that climbs out of the project and gets rejected by the test runner.
- [#2178](https://github.com/bbatsov/projectile/pull/2178): The file-extension filter of `projectile-replace` and friends is now shell-quoted. ag received it unquoted, so a `*.el` filter reached it as the regexp `.el$` and also matched files ending in `model` or `panel`; on the other tools an extension containing a quote broke the command outright.
Expand Down
114 changes: 49 additions & 65 deletions test/projectile-ignore-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,85 +232,69 @@
(clrhash projectile--glob-keep-warned-projects)
(clrhash projectile--prefixless-dirconfig-warned-projects))
(it "parses dirconfig and returns directories to ignore and keep"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'file-truename :and-call-fake (lambda (filename) filename))
(spy-on 'insert-file-contents :and-call-fake
(lambda (filename)
(save-excursion (insert "\n-exclude\n+include\n#may-be-a-comment\nno-prefix\n left-wspace\nright-wspace\t\n"))))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig
:keep '("include/")
:ignore '("exclude"
"#may-be-a-comment"
"no-prefix"
"left-wspace"
"right-wspace")
:prefixless-ignore '("#may-be-a-comment"
"no-prefix"
"left-wspace"
"right-wspace")))
;; same test - but with comment lines enabled using prefix '#'
(let ((projectile-dirconfig-comment-prefix ?#))
(projectile-test-with-project
((".projectile" . "\n-exclude\n+include\n#may-be-a-comment\nno-prefix\n left-wspace\nright-wspace\t\n"))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig
:keep '("include/")
:ignore '("exclude"
"#may-be-a-comment"
"no-prefix"
"left-wspace"
"right-wspace")
:prefixless-ignore '("no-prefix"
:prefixless-ignore '("#may-be-a-comment"
"no-prefix"
"left-wspace"
"right-wspace")))))
(it "drops comment lines when a comment prefix is set"
(projectile-test-with-project
((".projectile" . "\n-exclude\n+include\n#may-be-a-comment\nno-prefix\n left-wspace\nright-wspace\t\n"))
(let ((projectile-dirconfig-comment-prefix ?#))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig
:keep '("include/")
:ignore '("exclude"
"no-prefix"
"left-wspace"
"right-wspace")
:prefixless-ignore '("no-prefix"
"left-wspace"
"right-wspace"))))))
(it "skips leading whitespace before dispatching on the prefix"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'insert-file-contents :and-call-fake
(lambda (_filename)
(save-excursion
(insert " -indented-exclude\n"
"\t+indented-include\n"
" !indented-ensure\n"
" no-prefix-indented\n"))))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig
:keep '("indented-include/")
:ignore '("indented-exclude" "no-prefix-indented")
:ensure '("indented-ensure")
:prefixless-ignore '("no-prefix-indented"))))
(it "treats indented comment-prefix lines as comments"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'insert-file-contents :and-call-fake
(lambda (_filename)
(save-excursion
(insert " # indented comment\n"
"-keep-this\n"))))
(let ((projectile-dirconfig-comment-prefix ?#))
(projectile-test-with-project
((".projectile" . (concat " -indented-exclude\n"
"\t+indented-include\n"
" !indented-ensure\n"
" no-prefix-indented\n")))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig :ignore '("keep-this")))))
:to-equal (make-projectile-dirconfig
:keep '("indented-include/")
:ignore '("indented-exclude" "no-prefix-indented")
:ensure '("indented-ensure")
:prefixless-ignore '("no-prefix-indented")))))
(it "treats indented comment-prefix lines as comments"
(projectile-test-with-project
((".projectile" . " # indented comment\n-keep-this\n"))
(let ((projectile-dirconfig-comment-prefix ?#))
(expect (projectile-parse-dirconfig-file)
:to-equal (make-projectile-dirconfig :ignore '("keep-this"))))))
(it "warns once per project even when multiple + entries contain globs"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'insert-file-contents :and-call-fake
(lambda (_filename)
(save-excursion (insert "+/*.json\n+/src\n+/[abc]/lib\n"))))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(projectile-parse-dirconfig-file)
(expect 'display-warning :to-have-been-called-times 1))
(projectile-test-with-project
((".projectile" . "+/*.json\n+/src\n+/[abc]/lib\n"))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(projectile-parse-dirconfig-file)
(expect 'display-warning :to-have-been-called-times 1)))
(it "does not warn for plain + subdirectory entries"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'insert-file-contents :and-call-fake
(lambda (_filename)
(save-excursion (insert "+/src\n+/tests/foo\n"))))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(expect 'display-warning :not :to-have-been-called))
(projectile-test-with-project ((".projectile" . "+/src\n+/tests/foo\n"))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(expect 'display-warning :not :to-have-been-called)))
(it "does not warn for - ignore entries that contain globs"
(spy-on 'file-exists-p :and-return-value t)
(spy-on 'insert-file-contents :and-call-fake
(lambda (_filename)
(save-excursion (insert "-*.json\n-build/*.tmp\n"))))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(expect 'display-warning :not :to-have-been-called)))
(projectile-test-with-project ((".projectile" . "-*.json\n-build/*.tmp\n"))
(spy-on 'display-warning)
(projectile-parse-dirconfig-file)
(expect 'display-warning :not :to-have-been-called))))

(describe "projectile-parse-dirconfig-file with a real file"
(before-each
Expand Down
5 changes: 0 additions & 5 deletions test/projectile-test-helpers.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@

;;; Code:

;; needed for the tests to work with native compilation
(with-eval-after-load 'comp
(push 'insert-file-contents
native-comp-never-optimize-functions))

(require 'projectile)
(require 'buttercup)

Expand Down
Loading