Skip to content

Spurious sesman-related test coverage #3468

Closed as not planned
Closed as not planned
@vemv

Description

@vemv

Context

I recently found out that some of our sesman-related tests are not realistic, because they are implemented with the following macro:

(defmacro with-repl-buffer (ses-name type symbol &rest body)
  `(with-temp-buffer
     (sesman-add-object 'CIDER ,ses-name (current-buffer) t) ;; <------------
     ...

..that sesman-add-object does not represent a real call that CIDER performs.

This is highly problematic because by 'hardcoding' this session linking:

  • we cannot exercise cider--sesman-friendly-session-p, which is a critical function for a functional and fast UX.
  • some of the tests assert behavior that isn't CIDER's behavior at all.

The latter point is demonstrated by the following test:

(describe "when active connections are available"
(it "always returns the latest connection"
(let ((default-directory (expand-file-name "/tmp/a-dir")))
(with-repl-buffer ses-name 'clj bb1
(with-repl-buffer ses-name 'cljs bb2
(with-repl-buffer ses-name 'clj b1
(with-repl-buffer ses-name 'cljs b2
(expect (cider-current-repl) :to-equal b2)
;; follows type arguments
(expect (cider-current-repl 'clj) :to-equal b1)
(expect (cider-current-repl 'cljs) :to-equal b2)
;; follows file type
(with-temp-buffer
(setq major-mode 'clojure-mode)
(expect (cider-current-repl) :to-equal b1))
(with-temp-buffer
(setq major-mode 'clojurescript-mode)
(expect (cider-current-repl) :to-equal b2))))))))

CIDER's real behavior is: when active connections are available, only returns the latest connection if the given buffer is linked to it, or considered friendly to it.

Task

  • Make defmacro with-repl-buffer more realistic
  • Adapt affected tests to reflect CIDER's behavior
  • Add more direct test coverage to cider--sesman-friendly-session-p

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions