Skip to content

Commit 6f83c0b

Browse files
committed
[Fix #1143] Handle tests without location metadata
Evaluating test definitions interactivity creates vars without location metadata and we can't navigate to those definitions in case of test failures. There's no real solution to this problem other than fixing it in nREPL itself. For the time being we'll simply ignore such tests in our error highlighting logic.
1 parent 1ffa461 commit 6f83c0b

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [#1135](https://github.com/clojure-emacs/cider/pull/1135): Fix a corner case with locals display in the debugger.
1616
* [#1129](https://github.com/clojure-emacs/cider/issues/1129): Fix occasional `(wrong-type-argument stringp nil)` on clojure-android.
1717
* [#1122](https://github.com/clojure-emacs/cider/issues/1122): Run client initialization in new client buffer.
18+
* [#1143](https://github.com/clojure-emacs/cider/issues/1143): Handle tests without location metadata.
1819

1920
## 0.9.0 / 2015-06-16
2021

cider-test.el

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,21 +344,25 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
344344
(defun cider-test-highlight-problem (buffer test)
345345
"Highlight the BUFFER test definition for the non-passing TEST."
346346
(with-current-buffer buffer
347-
(nrepl-dbind-response test (type line message expected actual)
348-
(save-excursion
349-
(goto-char (point-min))
350-
(forward-line (1- line))
351-
(forward-whitespace 1)
352-
(forward-char)
353-
(let ((beg (point)))
354-
(forward-sexp)
355-
(let ((overlay (make-overlay beg (point))))
356-
(overlay-put overlay 'font-lock-face (cider-test-type-face type))
357-
(overlay-put overlay 'type type)
358-
(overlay-put overlay 'help-echo message)
359-
(overlay-put overlay 'message message)
360-
(overlay-put overlay 'expected expected)
361-
(overlay-put overlay 'actual actual)))))))
347+
(nrepl-dbind-response test (type file line message expected actual)
348+
;; we have to watch out for vars without proper location metadata
349+
;; right now everything evaluated interactively lacks this data
350+
;; TODO: Figure out what to do when the metadata is missing
351+
(when (and file line (not (cider--tooling-file-p file)))
352+
(save-excursion
353+
(goto-char (point-min))
354+
(forward-line (1- line))
355+
(forward-whitespace 1)
356+
(forward-char)
357+
(let ((beg (point)))
358+
(forward-sexp)
359+
(let ((overlay (make-overlay beg (point))))
360+
(overlay-put overlay 'font-lock-face (cider-test-type-face type))
361+
(overlay-put overlay 'type type)
362+
(overlay-put overlay 'help-echo message)
363+
(overlay-put overlay 'message message)
364+
(overlay-put overlay 'expected expected)
365+
(overlay-put overlay 'actual actual))))))))
362366

363367
(defun cider-test-highlight-problems (ns results)
364368
"Highlight all non-passing tests in the NS test RESULTS."

0 commit comments

Comments
 (0)