summaryrefslogtreecommitdiff
path: root/cider-test.el
diff options
context:
space:
mode:
authorNick Alexander <nalexander@mozilla.com>2017-01-03 15:12:34 -0800
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2017-01-04 23:30:06 +0200
commita4d85b603e12a8edd4acd41671e3bec799244e1e (patch)
treeda5e17024a07910d3d4a3fdc9207b0a85429b870 /cider-test.el
parent72b0caaedb79be834eda54d64406e29254d52329 (diff)
[Fix #1776] Add new customization variable `cider-test-defining-forms`.
This fix is strictly simpler than that suggested in https://github.com/clojure-emacs/cider/issues/1776#issuecomment-223758069. 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.)
Diffstat (limited to 'cider-test.el')
-rw-r--r--cider-test.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/cider-test.el b/cider-test.el
index f5fd3e6c..8aa7a4d2 100644
--- a/cider-test.el
+++ b/cider-test.el
@@ -59,6 +59,15 @@
:group 'cider-test
:package-version '(cider . "0.9.0"))
+(defcustom cider-test-defining-forms '("deftest" "defspec")
+ "Forms that define individual tests.
+CIDER considers the top-level form around point to define a test if the
+form starts with one of these forms.
+Add to this list to have CIDER recognize additional test defining macros."
+ :type '(repeat string)
+ :group 'cider-test
+ :package-version '(cider . "0.15.0"))
+
(defvar cider-test-last-summary nil
"The summary of the last run test.")
@@ -680,7 +689,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-forms))
(progn
(cider-test-update-last-test ns (cdr def))
(cider-test-execute ns (cdr def)))