Skip to content

Commit

Permalink
Refine Sesman session linking to accurately work on `*cider-test-repo…
Browse files Browse the repository at this point in the history
…rt*` buffers

Fixes #3533
  • Loading branch information
vemv committed Oct 17, 2023
1 parent 27ed547 commit 315494a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bugs fixed

- [#3533](https://github.com/clojure-emacs/cider/issues/3533): Refine Sesman session linking to accurately work on `*cider-test-report*` buffers.

### Changes

- [#3521](https://github.com/clojure-emacs/cider/issues/3521): Expand `cider-clojure-compilation-regexp` to also match e.g. `Unexpected error (ExceptionInfo) macroexpanding defmulti at (src/ns.clj:1:1).`.
Expand Down
23 changes: 18 additions & 5 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -1762,16 +1762,29 @@ constructs."
The checking is done as follows:
* Consider if the buffer belongs to `cider-ancillary-buffers`
* If the current buffer's name equals to the value of `cider-test-report-buffer',
only accept the given session's repl if it equals `cider-test--current-repl'
* Consider if the buffer belongs to `cider-ancillary-buffers'
* Consider the buffer's filename, strip any Docker/TRAMP details from it
* Check if that filename belongs to the classpath,
or to the classpath roots (e.g. the project root dir)
* As a fallback, check if the buffer's ns form
matches any of the loaded namespaces."
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
(or (member (buffer-name) cider-ancillary-buffers)
(when-let* ((repl (cadr session))
(proc (get-buffer-process repl))
(when-let ((repl (cadr session)))
(cond
((equal (buffer-name)
cider-test-report-buffer)
(or (not cider-test--current-repl)
(not (buffer-live-p cider-test--current-repl))
(equal repl
cider-test--current-repl)))

((member (buffer-name) cider-ancillary-buffers)
t)

(t
(when-let* ((proc (get-buffer-process repl))
(file (file-truename (or (buffer-file-name) default-directory))))
;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
(when (string-match-p "#uzip" file)
Expand Down Expand Up @@ -1826,7 +1839,7 @@ The checking is done as follows:
(member ns (nrepl-dict-keys cider-repl-ns-cache)))
(member ns ns-list))))
(when debug
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))))

(defun cider-debug-sesman-friendly-session-p ()
"`message's debugging information relative to friendly sessions.
Expand Down
9 changes: 8 additions & 1 deletion cider-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@

(make-obsolete 'cider-test-defining-forms nil "1.8.0")

(defvar cider-test--current-repl nil
"Contains the reference to the REPL where the tests were last invoked from.
This is needed for *cider-test-report* navigation
to work against the correct REPL session.")

(defvar cider-test-last-summary nil
"The summary of the last run test.")

Expand Down Expand Up @@ -289,7 +294,8 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
cider-auto-select-error-buffer
#'cider-stacktrace-mode
'ancillary)
(reverse causes))))))))))
(reverse causes)))))))
cider-test--current-repl)))

(defun cider-test-stacktrace ()
"Display stacktrace for the erring test at point."
Expand Down Expand Up @@ -710,6 +716,7 @@ running them."
;; we generate a different message when running individual tests
(cider-test-echo-running ns (car tests))
(cider-test-echo-running ns)))
(setq cider-test--current-repl conn)
(let* ((retest? (eq :non-passing ns))
(request `("op" ,(cond ((stringp ns) "test")
((eq :project ns) "test-all")
Expand Down

0 comments on commit 315494a

Please sign in to comment.