aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@toptal.com>2026-04-26 11:17:21 +0100
committerBozhidar Batsov <bozhidar@toptal.com>2026-04-26 11:17:21 +0100
commitc65f0d4f77aa1db4a5c8f42dea44e10494629da0 (patch)
tree1cdbd1d8be78141ee26b81e4bceb182f7ec825cf /test
parent1ed5e991582a07688d794a03fe648d71afb53771 (diff)
Add tests for hybrid indexing
The hybrid path through `projectile-dir-files` had zero direct coverage. Add tests that verify it applies `projectile-globally-ignored-file-suffixes` and dirconfig ignore patterns on top of the alien result, and that the resolved VCS is threaded through to `projectile-dir-files-alien` exactly once. Also adds a focused test for `projectile-dir-files-alien` honoring an explicitly supplied VCS argument without re-running `projectile-project-vcs`.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el73
1 files changed, 72 insertions, 1 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 4d56d4d..a546a8f 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -919,7 +919,78 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(delete-file "deleted.txt")
(let ((files (projectile-dir-files-alien default-directory)))
(expect files :to-contain "existing.txt")
- (expect files :not :to-contain "deleted.txt")))))))
+ (expect files :not :to-contain "deleted.txt"))))))
+ (it "uses the VCS argument when supplied without recomputing it"
+ (spy-on 'projectile-project-vcs)
+ (spy-on 'projectile-files-via-ext-command :and-return-value '("a"))
+ (spy-on 'projectile-get-sub-projects-files :and-return-value nil)
+ (spy-on 'projectile-git-deleted-files :and-return-value nil)
+ (let ((projectile-git-use-fd nil)
+ (projectile-fd-executable nil))
+ (projectile-dir-files-alien "/my/root/" 'git))
+ (expect 'projectile-project-vcs :not :to-have-been-called)))
+
+(describe "hybrid indexing"
+ (it "applies projectile-globally-ignored-file-suffixes on top of the alien result"
+ (spy-on 'projectile-files-via-ext-command :and-return-value
+ '("foo.el" "build/foo.elc" "README"))
+ (spy-on 'projectile-get-sub-projects-files :and-return-value nil)
+ (spy-on 'projectile-git-deleted-files :and-return-value nil)
+ (spy-on 'projectile-project-vcs :and-return-value 'git)
+ (spy-on 'projectile-project-root :and-return-value "/my/root/")
+ (spy-on 'file-directory-p :and-call-fake
+ (lambda (filename) (equal filename "/my/root/")))
+ (spy-on 'projectile-parse-dirconfig-file :and-return-value nil)
+ (let ((projectile-indexing-method 'hybrid)
+ (projectile-enable-caching nil)
+ (projectile-globally-ignored-file-suffixes '(".elc"))
+ (projectile-globally-ignored-files nil)
+ (projectile-globally-ignored-directories nil)
+ (projectile-globally-unignored-files nil)
+ (projectile-globally-unignored-directories nil)
+ (projectile-git-use-fd nil)
+ (projectile-fd-executable nil))
+ (let ((files (projectile-dir-files "/my/root/")))
+ (expect files :to-contain "foo.el")
+ (expect files :to-contain "README")
+ (expect files :not :to-contain "build/foo.elc"))))
+ (it "honors dirconfig ignore patterns on top of the alien result"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/keep.txt"
+ "project/drop.txt"
+ "project/.projectile")
+ (let ((root (file-truename (expand-file-name "project/"))))
+ (with-temp-file (expand-file-name ".projectile" root)
+ (insert "-/drop.txt\n"))
+ (spy-on 'projectile-project-root :and-return-value root)
+ (spy-on 'projectile-project-vcs :and-return-value 'git)
+ (spy-on 'projectile-files-via-ext-command :and-return-value
+ '("keep.txt" "drop.txt"))
+ (spy-on 'projectile-get-sub-projects-files :and-return-value nil)
+ (spy-on 'projectile-git-deleted-files :and-return-value nil)
+ (let ((projectile-indexing-method 'hybrid)
+ (projectile-enable-caching nil)
+ (projectile-git-use-fd nil)
+ (projectile-fd-executable nil))
+ (let ((files (projectile-dir-files root)))
+ (expect files :to-contain "keep.txt")
+ (expect files :not :to-contain "drop.txt")))))))
+ (it "passes the resolved VCS to projectile-dir-files-alien"
+ (spy-on 'projectile-project-vcs :and-return-value 'git)
+ (spy-on 'projectile-dir-files-alien :and-return-value '("a"))
+ (spy-on 'projectile-adjust-files :and-call-fake (lambda (_p _v files) files))
+ (spy-on 'file-directory-p :and-call-fake
+ (lambda (filename) (equal filename "/my/root/")))
+ (let ((projectile-indexing-method 'hybrid)
+ (projectile-enable-caching nil))
+ (projectile-dir-files "/my/root/"))
+ ;; vcs is resolved once by the dispatcher and threaded through; the
+ ;; redundant call inside projectile-dir-files-alien is gone.
+ (expect 'projectile-project-vcs :to-have-been-called-times 1)
+ (expect 'projectile-dir-files-alien
+ :to-have-been-called-with "/my/root/" 'git)))
(describe "projectile-project-dirs"
(it "includes intermediate directories that contain only subdirectories"