branch: elpa/cider
commit 017ecc8b53d8ecac15487ee9d381cf8578eb30c3
Author: vemv <[email protected]>
Commit: GitHub <[email protected]>
`cider-test`: make test vars in test results reports clickable (#3583)
Fixes https://github.com/clojure-emacs/cider/issues/3580
---
CHANGELOG.md | 2 ++
cider-test.el | 9 ++++++++-
doc/modules/ROOT/pages/testing/test_reports.adoc | 17 +++++++++++++++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 770301bf05..56c851feca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@
- [#3576](https://github.com/clojure-emacs/cider/issues/3576): CIDER
[Inspector](https://docs.cider.mx/cider/debugging/inspector.html): display Java
class/method/field block tags (Returns/Throws/Params info) when available.
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html):
retain
[`truncate-lines`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html)
values across screens.
+- [#3580](https://github.com/clojure-emacs/cider/issues/3580): `cider-test`:
make test vars in [test results
reports](https://docs.cider.mx/cider/testing/test_reports.html) clickable.
+ - As defined in the newly introduced `cider-test-var-keymap` var.
## 1.11.1 (2023-11-11)
diff --git a/cider-test.el b/cider-test.el
index d4e75e9b16..b5df76d35f 100644
--- a/cider-test.el
+++ b/cider-test.el
@@ -407,6 +407,11 @@ With the actual value, the outermost '(not ...)'
s-expression is removed."
(and (string-match-p "\\\\n" input-string)
t)))
+(defvar cider-test-var-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map [mouse-1] #'cider-test-jump)
+ map))
+
(defun cider-test-render-assertion (buffer test)
"Emit into BUFFER report detail for the TEST assertion."
(with-current-buffer buffer
@@ -428,7 +433,9 @@ With the actual value, the outermost '(not ...)'
s-expression is removed."
(type-face (cider-test-type-simple-face type))
(bg `(:background ,cider-test-items-background-color :extend
t)))
(cider-insert (capitalize type) type-face nil " in ")
- (cider-insert var 'font-lock-function-name-face t)
+ (cider-propertize-region `(keymap ,cider-test-var-keymap)
+ (cider-insert (propertize var 'mouse-face 'highlight)
+ 'font-lock-function-name-face t))
(when context (cider-insert context 'font-lock-doc-face t))
(when message (cider-insert message 'font-lock-string-face t))
(when expected
diff --git a/doc/modules/ROOT/pages/testing/test_reports.adoc
b/doc/modules/ROOT/pages/testing/test_reports.adoc
index 9199ddf798..1af8d8d946 100644
--- a/doc/modules/ROOT/pages/testing/test_reports.adoc
+++ b/doc/modules/ROOT/pages/testing/test_reports.adoc
@@ -11,38 +11,51 @@ Calling test commands again will update the test report.
TIP: You can also
xref:testing/running_tests.adoc#display-test-report-on-success[configure test
reports to be displayed on success].
|===
-| Keyboard shortcut | Description
+| Keyboard shortcut | Command name | Description
| kbd:[g]
+| `cider-test-run-test`
| Run test at point.
| kbd:[n]
+| `cider-test-run-ns-tests`
| Run tests for current namespace.
| kbd:[s]
+| `cider-test-run-ns-tests-with-filters`
| Run tests for current namespace with selector filter.
| kbd:[l]
+| `cider-test-run-loaded-tests`
| Run tests for all loaded namespaces.
| kbd:[p]
+| `cider-test-run-project-tests`
| Run tests for all project namespaces. This loads the additional namespaces.
| kbd:[f]
+| `cider-test-rerun-failed-tests`
| Re-run test failures/errors.
| kbd:[M-p]
+| `cider-test-previous-result`
| Move point to previous test.
| kbd:[M-n]
+| `cider-test-next-result`
| Move point to next test.
-| kbd:[t] or kbd:[M-.]
+| kbd:[t] or kbd:[M-.] or kbd:click
+| `cider-test-jump`
| Jump to test definition.
| kbd:[d]
+| `cider-test-ediff`
| Display diff of actual vs expected.
| kbd:[e]
+| `cider-test-stacktrace`
| Display test error cause and stacktrace info.
|===
+
+Most key bindings are defined in `cider-test-report-mode-map`, while the
`click` behavior is defined in `cider-test-var-keymap`.