Skip to content

Commit

Permalink
[Fix clojure-emacs#1776] Add new customization variable `cider-test-d…
Browse files Browse the repository at this point in the history
…efining-names`.

This fix is strictly simpler than that suggested in
clojure-emacs#1776 (comment).  It
has the advantage of being much more robust.

I partially implemented the suggested fix, and witnessed the following two
issues.  First, full "macroexpand" does not leave a recognizable `deftest` form;
it generally leaves a `(def test-... (fn [] ...))` sexp.  That implies that a
recursive macroexpansion would be required, with each step of the recursion
checking for a recognized form.  Second, even recognizing such a form is tricky,
because the expansion may refer to deftest in an aliased namespace (e.g.,
`t/deftest` or `clojure.test/deftest` rather than bare `deftest`).  One could
then try to identify possible namespaces using the current environment, but this
is getting complicated.

Therefore, I think it better to have the user configure their environment to
help them solve this problem.  (And, of course, future work can implement the
full macroexpansion approach.)
  • Loading branch information
ncalexan committed Jan 3, 2017
1 parent 1d33533 commit f0bff5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Add new customization variable `cider-special-mode-truncate-lines`.
* Add an option `cider-inspector-fill-frame` to control whether the cider inspector window fills its frame.
* [#1893](https://github.com/clojure-emacs/cider/issues/1893)Add negative prefix argument to `cider-refresh` to inhibit invoking of cider-refresh-functions
* [#1776](https://github.com/clojure-emacs/cider/issues/1776)Add new customization variable `cider-test-defining-names` allowing new test defining macro names to be recognized.

### Changes

Expand Down
8 changes: 7 additions & 1 deletion cider-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
:group 'cider-test
:package-version '(cider . "0.9.0"))

(defcustom cider-test-defining-names '("deftest" "defspec")
"Macro names that define individual tests."
:type 'list
:group 'cider-test
:package-version '(cider . "0.15.0"))

(defvar cider-test-last-summary nil
"The summary of the last run test.")

Expand Down Expand Up @@ -680,7 +686,7 @@ is searched."
(cider-test-execute ns (list var)))
(let ((ns (clojure-find-ns))
(def (clojure-find-def)))
(if (and ns (member (car def) '("deftest" "defspec")))
(if (and ns (member (car def) cider-test-defining-names))
(progn
(cider-test-update-last-test ns (cdr def))
(cider-test-execute ns (cdr def)))
Expand Down

0 comments on commit f0bff5f

Please sign in to comment.