diff options
| author | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-25 19:00:09 +0100 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-25 19:00:09 +0100 |
| commit | 5e4471b10dc59274e7608489b28897a69c585cc8 (patch) | |
| tree | a25ccb579536dcba4c35066fdfa74254e5cc288d /test | |
| parent | 54387baa2e2bd7af9866abd27f5454da71cdbd22 (diff) | |
Warn when alien indexing bypasses a populated .projectile
Under alien indexing the dirconfig file is silently ignored, which
is the most common confusion in the issue tracker (#1322, #1075,
#1534, #1941). Show a one-shot display-warning the first time we
index a project where alien mode meets a non-empty .projectile.
The new projectile-warn-when-dirconfig-is-ignored option lets users
who already understand the trade-off silence the warning.
Diffstat (limited to 'test')
| -rw-r--r-- | test/projectile-test.el | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index f874a83..f460194 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -633,6 +633,69 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. (projectile-invalidate-cache nil) (expect (gethash root projectile--dirconfig-cache) :to-be nil)))))) +(describe "alien-mode dirconfig warning" + (before-each + (clrhash projectile--alien-dirconfig-warned-projects)) + (it "warns once when alien indexing skips a populated .projectile" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (with-temp-file (expand-file-name ".projectile" root) + (insert "-foo\n")) + (spy-on 'projectile-project-root :and-return-value root) + (spy-on 'projectile-dir-files-alien :and-return-value '("a")) + (spy-on 'display-warning) + (let ((projectile-indexing-method 'alien) + (projectile-enable-caching nil) + (projectile-warn-when-dirconfig-is-ignored t)) + (projectile-project-files root) + (projectile-project-files root)) + (expect 'display-warning :to-have-been-called-times 1))))) + (it "does not warn for an empty .projectile" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (spy-on 'projectile-project-root :and-return-value root) + (spy-on 'projectile-dir-files-alien :and-return-value '("a")) + (spy-on 'display-warning) + (let ((projectile-indexing-method 'alien) + (projectile-enable-caching nil) + (projectile-warn-when-dirconfig-is-ignored t)) + (projectile-project-files root)) + (expect 'display-warning :not :to-have-been-called))))) + (it "does not warn when the warning is disabled" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (with-temp-file (expand-file-name ".projectile" root) + (insert "-foo\n")) + (spy-on 'projectile-project-root :and-return-value root) + (spy-on 'projectile-dir-files-alien :and-return-value '("a")) + (spy-on 'display-warning) + (let ((projectile-indexing-method 'alien) + (projectile-enable-caching nil) + (projectile-warn-when-dirconfig-is-ignored nil)) + (projectile-project-files root)) + (expect 'display-warning :not :to-have-been-called))))) + (it "does not warn under non-alien indexing" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (with-temp-file (expand-file-name ".projectile" root) + (insert "-foo\n")) + (spy-on 'projectile-project-root :and-return-value root) + (spy-on 'projectile-get-project-directories :and-return-value '()) + (spy-on 'display-warning) + (let ((projectile-indexing-method 'native) + (projectile-enable-caching nil) + (projectile-warn-when-dirconfig-is-ignored t)) + (projectile-project-files root)) + (expect 'display-warning :not :to-have-been-called)))))) + (describe "projectile-get-project-directories" (it "gets the list of project directories" (spy-on 'projectile-project-root :and-return-value "/my/root/") |
