diff options
| author | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-27 07:48:07 +0000 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-27 07:48:07 +0000 |
| commit | fc8559850228f54efbc7ee4ea56b2e376cec5b04 (patch) | |
| tree | 840af3bf3617a5dad6e3234778c7a3729bcab034 /test | |
| parent | a55eeb2b1821c5252a5ea3d8c7c79728a42763fe (diff) | |
Persist disk cache in projectile-purge-dir-from-cache
`projectile-purge-file-from-cache' writes the updated file list to
disk under persistent caching; the directory variant only mutated
the in-memory hash, so the purged subtree would reappear on the
next Emacs session. Mirror the persistence step here.
Diffstat (limited to 'test')
| -rw-r--r-- | test/projectile-test.el | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index e21effb..9e4c358 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -3232,6 +3232,40 @@ projectile-process-current-project-buffers-current to have similar behaviour" ;; projectile-serialize should be called with the updated list, not the stale one (expect 'projectile-serialize :to-have-been-called-with '("foo.el" "baz.el") "/tmp/cache.eld")))) +(describe "projectile-purge-dir-from-cache" + (it "removes files under the directory from the in-memory cache" + (let ((projectile-projects-cache (make-hash-table :test 'equal)) + (projectile-enable-caching t)) + (puthash "/project/" + '("src/foo.el" "src/sub/bar.el" "test/baz.el") + projectile-projects-cache) + (spy-on 'projectile-project-root :and-return-value "/project/") + (projectile-purge-dir-from-cache "src/") + (expect (gethash "/project/" projectile-projects-cache) + :to-equal '("test/baz.el")))) + (it "serializes the updated cache when persistent caching is enabled" + (let ((projectile-projects-cache (make-hash-table :test 'equal)) + (projectile-enable-caching 'persistent)) + (puthash "/project/" + '("src/foo.el" "src/sub/bar.el" "test/baz.el") + projectile-projects-cache) + (spy-on 'projectile-project-root :and-return-value "/project/") + (spy-on 'projectile-serialize) + (spy-on 'projectile-project-cache-file :and-return-value "/tmp/cache.eld") + (projectile-purge-dir-from-cache "src/") + (expect 'projectile-serialize + :to-have-been-called-with '("test/baz.el") "/tmp/cache.eld"))) + (it "does not touch disk when persistent caching is disabled" + (let ((projectile-projects-cache (make-hash-table :test 'equal)) + (projectile-enable-caching t)) + (puthash "/project/" + '("src/foo.el" "test/baz.el") + projectile-projects-cache) + (spy-on 'projectile-project-root :and-return-value "/project/") + (spy-on 'projectile-serialize) + (projectile-purge-dir-from-cache "src/") + (expect 'projectile-serialize :not :to-have-been-called)))) + (describe "projectile-default-generic-command" (it "returns a string command as-is" (let ((projectile-project-types '((test-type compile-command "make")))) |
