Skip to content

Commit 315494a

Browse files
committed
Refine Sesman session linking to accurately work on *cider-test-report* buffers
Fixes #3533
1 parent 27ed547 commit 315494a

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
@@ -1762,16 +1762,29 @@ constructs."
17621762
17631763
The checking is done as follows:
17641764
1765-
* Consider if the buffer belongs to `cider-ancillary-buffers`
1765+
* If the current buffer's name equals to the value of `cider-test-report-buffer',
1766+
only accept the given session's repl if it equals `cider-test--current-repl'
1767+
* Consider if the buffer belongs to `cider-ancillary-buffers'
17661768
* Consider the buffer's filename, strip any Docker/TRAMP details from it
17671769
* Check if that filename belongs to the classpath,
17681770
or to the classpath roots (e.g. the project root dir)
17691771
* As a fallback, check if the buffer's ns form
17701772
matches any of the loaded namespaces."
17711773
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
1772-
(or (member (buffer-name) cider-ancillary-buffers)
1773-
(when-let* ((repl (cadr session))
1774-
(proc (get-buffer-process repl))
1774+
(when-let ((repl (cadr session)))
1775+
(cond
1776+
((equal (buffer-name)
1777+
cider-test-report-buffer)
1778+
(or (not cider-test--current-repl)
1779+
(not (buffer-live-p cider-test--current-repl))
1780+
(equal repl
1781+
cider-test--current-repl)))
1782+
1783+
((member (buffer-name) cider-ancillary-buffers)
1784+
t)
1785+
1786+
(t
1787+
(when-let* ((proc (get-buffer-process repl))
17751788
(file (file-truename (or (buffer-file-name) default-directory))))
17761789
;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
17771790
(when (string-match-p "#uzip" file)
@@ -1826,7 +1839,7 @@ The checking is done as follows:
18261839
(member ns (nrepl-dict-keys cider-repl-ns-cache)))
18271840
(member ns ns-list))))
18281841
(when debug
1829-
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))
1842+
(list file "was not determined to belong to classpath:" classpath "or classpath-roots:" classpath-roots))))))))))
18301843

18311844
(defun cider-debug-sesman-friendly-session-p ()
18321845
"`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)