Skip to content

Commit fa127b8

Browse files
committed
Refine Sesman session linking to accurately work on *cider-test-report* buffers
Fixes #3533
1 parent 7b2e892 commit fa127b8

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
- [#3533](https://github.com/clojure-emacs/cider/issues/3533): Refine Sesman session linking to accurately work on `*cider-test-report*` buffers.
8+
59
### Changes
610

711
- [#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).`.

cider-repl.el

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,16 +1761,29 @@ constructs."
17611761
17621762
The checking is done as follows:
17631763
1764-
* Consider if the buffer belongs to `cider-ancillary-buffers`
1764+
* If the current buffer's name equals to the value of `cider-test-report-buffer',
1765+
only accept the given session's repl if it equals `cider-test--current-repl'
1766+
* Consider if the buffer belongs to `cider-ancillary-buffers'
17651767
* Consider the buffer's filename, strip any Docker/TRAMP details from it
17661768
* Check if that filename belongs to the classpath,
17671769
or to the classpath roots (e.g. the project root dir)
17681770
* As a fallback, check if the buffer's ns form
17691771
matches any of the loaded namespaces."
17701772
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
1771-
(or (member (buffer-name) cider-ancillary-buffers)
1772-
(when-let* ((repl (cadr session))
1773-
(proc (get-buffer-process repl))
1773+
(when-let ((repl (cadr session)))
1774+
(cond
1775+
((equal (buffer-name)
1776+
cider-test-report-buffer)
1777+
(or (not cider-test--current-repl)
1778+
(not (buffer-live-p cider-test--current-repl))
1779+
(equal repl
1780+
cider-test--current-repl)))
1781+
1782+
((member (buffer-name) cider-ancillary-buffers)
1783+
t)
1784+
1785+
(t
1786+
(when-let* ((proc (get-buffer-process repl))
17741787
(file (file-truename (or (buffer-file-name) default-directory))))
17751788
;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
17761789
(when (string-match-p "#uzip" file)
@@ -1825,7 +1838,7 @@ The checking is done as follows:
18251838
(member ns (nrepl-dict-keys cider-repl-ns-cache)))
18261839
(member ns ns-list))))
18271840
(when debug
1828-
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))
1841+
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))))
18291842

18301843
(defun cider-debug-sesman-friendly-session-p ()
18311844
"`message's debugging information relative to friendly sessions.

cider-test.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262

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

65+
(defvar cider-test--current-repl nil
66+
"Contains the reference to the REPL where the tests were last invoked from.
67+
This is needed for *cider-test-report* navigation
68+
to work against the correct REPL session.")
69+
6570
(defvar cider-test-last-summary nil
6671
"The summary of the last run test.")
6772

@@ -289,7 +294,8 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
289294
cider-auto-select-error-buffer
290295
#'cider-stacktrace-mode
291296
'ancillary)
292-
(reverse causes))))))))))
297+
(reverse causes)))))))
298+
cider-test--current-repl)))
293299

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

0 commit comments

Comments
 (0)