aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilipp Fehre <pfehre@twitter.com>2019-12-10 18:18:14 +0000
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2020-01-19 12:59:35 +0200
commitfd2eef93d1aadf254f695abb5c938ac5aa064e65 (patch)
tree9db9261358788cf5254206e4ae6d0f1ddc1f6bc2 /test
parent1e7b37f0ae07a6b4ac1b1a5f0e5422cfcb8e1c55 (diff)
Allow multiple root-dirs to be search by projectile-grep
When a project is configured via `.projectile` to include multiple directories explicitly this results in `projectile-grep` to run over multiple roots. ``` +/foo/bar +/baz/ ``` With a single global *grep* buffer this results in either a) losing all but the search result of the last root b) Stalling as the user is asked per root to kill the grep buffer To avoid this the name of the `*grep*` buffer should to include the current `root` being search associated with the buffer like `*grep <~/source/foo/bar>*`.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 0d56c57..32b915d 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -28,6 +28,7 @@
(require 'projectile)
(require 'buttercup)
+
(message "Running tests on Emacs %s" emacs-version)
;; TODO: Revise this init logic
@@ -643,6 +644,32 @@ You'd normally combine this with `projectile-test-with-sandbox'."
(expect (projectile-project-root) :to-equal correct-project-root))))))
(describe "projectile-grep"
+ (describe "multi-root grep"
+ (after-each
+ (cl-flet ((grep-buffer-p (b) (string-prefix-p "*grep" (buffer-name b))))
+ (let ((grep-buffers (cl-remove-if-not #'grep-buffer-p (buffer-list))))
+ (dolist (grep-buffer grep-buffers)
+ (let ((kill-buffer-query-functions nil))
+ (kill-buffer grep-buffer))))))
+ (it "grep multi-root projects"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/bar/"
+ "project/baz/")
+ (cd "project")
+ (with-temp-file ".projectile" (insert (concat "+/baz\n"
+ "+/bar\n")))
+ (with-temp-file "foo.txt" (insert "hi"))
+ (with-temp-file "bar/bar.txt" (insert "hi"))
+ (with-temp-file "baz/baz.txt" (insert "hi"))
+ (with-current-buffer (find-file-noselect ".projectile" t)
+ (let ((grep-find-template "<X>")
+ grep-find-ignored-directories grep-find-ignored-files
+ projectile-globally-ignored-files
+ projectile-globally-ignored-file-suffixes
+ projectile-globally-ignored-directories)
+ (projectile-grep "hi")))))))
+
(describe "rgrep"
(before-each
(spy-on 'compilation-start))