Skip to content

Commit 89ed540

Browse files
authored
Refine Sesman session linking to accurately work on *cider-test-report* buffers (#3535)
Fixes #3533
1 parent 7b2e892 commit 89ed540

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
### Bugs fixed
1818

19+
- [#3533](https://github.com/clojure-emacs/cider/issues/3533): Refine Sesman session linking to accurately work on `*cider-test-report*` buffers.
1920
- [#3539](https://github.com/clojure-emacs/cider/issues/3539): `cider-jump-to-locref-at-point`: don't jump to non-existing files.
2021

2122
## 1.8.2 (2023-10-15)

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: 20 additions & 10 deletions
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")
@@ -746,15 +753,18 @@ running them."
746753
(cider-test-echo-summary summary results elapsed-time)
747754
(if (or (not (zerop (+ error fail)))
748755
cider-test-show-report-on-success)
749-
(cider-test-render-report
750-
(cider-popup-buffer
751-
cider-test-report-buffer
752-
cider-auto-select-test-report-buffer)
753-
summary
754-
results
755-
elapsed-time
756-
ns-elapsed-time
757-
var-elapsed-time)
756+
(let ((b (cider-popup-buffer
757+
cider-test-report-buffer
758+
cider-auto-select-test-report-buffer)))
759+
(with-current-buffer b
760+
(setq-local default-directory nil))
761+
(cider-test-render-report
762+
b
763+
summary
764+
results
765+
elapsed-time
766+
ns-elapsed-time
767+
var-elapsed-time))
758768
(when (get-buffer cider-test-report-buffer)
759769
(with-current-buffer cider-test-report-buffer
760770
(let ((inhibit-read-only t))

0 commit comments

Comments
 (0)