Skip to content

cider-test: make test vars in test results reports clickable #3583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.