branch: elpa/cider
commit 989e2a69a7cc303f4df43077fe51c7b646565ef8
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Fix the cider-project-dir fallback test on Emacs 28
    
    The test mocked `project-current' with a literal `(vc Git root)' object,
    which is the Emacs 29+ shape.  On Emacs 28 a transient vc project is
    `(vc . root)' and `project-root' extracts the root differently, so the
    mock made `cider-project-dir' feed `(Git root)' to `expand-file-name'
    and throw.  Mock `project-current' and `project-root' at the public API
    boundary instead, so the test no longer depends on the internal project
    shape and passes on every supported Emacs.
---
 test/cider-util-tests.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/cider-util-tests.el b/test/cider-util-tests.el
index efe39d202e..47b16ec19b 100644
--- a/test/cider-util-tests.el
+++ b/test/cider-util-tests.el
@@ -536,7 +536,13 @@ and some other vars (like clojure.core/filter).
         (expect (cider-project-dir sub) :to-equal sub)))
 
     (it "falls back to project-current when no build-tool file is found"
-      (spy-on 'project-current :and-return-value `(vc Git ,root))
+      ;; Mock at the public API boundary.  The internal shape of a project
+      ;; object, and how `project-root' extracts the root from it, differs
+      ;; across Emacs versions (on Emacs 28 a vc project is `(vc . root)',
+      ;; on 29+ it is `(vc Backend root)'), so hard-coding one shape breaks
+      ;; the other.
+      (spy-on 'project-current :and-return-value 'fake-project)
+      (spy-on 'project-root :and-return-value root)
       (expect (cider-project-dir root) :to-equal root))
 
     (it "returns nil when there is neither a build-tool file nor a project"

Reply via email to