Skip to content

Commit

Permalink
cider-test: make test vars in test results reports clickable
Browse files Browse the repository at this point in the history
Fixes #3580
  • Loading branch information
vemv committed Nov 13, 2023
1 parent 1b97fe3 commit 14d9fdc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 8 additions & 1 deletion cider-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 15 additions & 2 deletions doc/modules/ROOT/pages/testing/test_reports.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit 14d9fdc

Please sign in to comment.