Skip to content

Commit

Permalink
[Fix #1143] Handle tests without location metadata
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bbatsov committed Jun 23, 2015
1 parent 1ffa461 commit 6f83c0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [#1135](https://github.com/clojure-emacs/cider/pull/1135): Fix a corner case with locals display in the debugger.
* [#1129](https://github.com/clojure-emacs/cider/issues/1129): Fix occasional `(wrong-type-argument stringp nil)` on clojure-android.
* [#1122](https://github.com/clojure-emacs/cider/issues/1122): Run client initialization in new client buffer.
* [#1143](https://github.com/clojure-emacs/cider/issues/1143): Handle tests without location metadata.

## 0.9.0 / 2015-06-16

Expand Down
34 changes: 19 additions & 15 deletions cider-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -344,21 +344,25 @@ With the actual value, the outermost '(not ...)' s-expression is removed."
(defun cider-test-highlight-problem (buffer test)
"Highlight the BUFFER test definition for the non-passing TEST."
(with-current-buffer buffer
(nrepl-dbind-response test (type line message expected actual)
(save-excursion
(goto-char (point-min))
(forward-line (1- line))
(forward-whitespace 1)
(forward-char)
(let ((beg (point)))
(forward-sexp)
(let ((overlay (make-overlay beg (point))))
(overlay-put overlay 'font-lock-face (cider-test-type-face type))
(overlay-put overlay 'type type)
(overlay-put overlay 'help-echo message)
(overlay-put overlay 'message message)
(overlay-put overlay 'expected expected)
(overlay-put overlay 'actual actual)))))))
(nrepl-dbind-response test (type file line message expected actual)
;; we have to watch out for vars without proper location metadata
;; right now everything evaluated interactively lacks this data
;; TODO: Figure out what to do when the metadata is missing
(when (and file line (not (cider--tooling-file-p file)))
(save-excursion
(goto-char (point-min))
(forward-line (1- line))
(forward-whitespace 1)
(forward-char)
(let ((beg (point)))
(forward-sexp)
(let ((overlay (make-overlay beg (point))))
(overlay-put overlay 'font-lock-face (cider-test-type-face type))
(overlay-put overlay 'type type)
(overlay-put overlay 'help-echo message)
(overlay-put overlay 'message message)
(overlay-put overlay 'expected expected)
(overlay-put overlay 'actual actual))))))))

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

0 comments on commit 6f83c0b

Please sign in to comment.