Skip to content
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

[Fix #1776] Add new customization variable cider-test-defining-names. #1906

Merged
merged 1 commit into from Jan 4, 2017

Conversation

ncalexan
Copy link
Contributor

@ncalexan ncalexan commented Jan 3, 2017

This fix is strictly simpler than that suggested in
#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.)


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • [n/a] You've added tests (if possible) to cover your change(s)
  • All tests are passing (make test)
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • [n/a] You've updated the readme (if adding/changing user-visible functionality)
  • [n/a] You've updated the refcard (if you made changes to the commands listed there)

Thanks!

@@ -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."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should expand the description here - if I didn't know what this was about I'd never figure it out. :-)

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual type should be '(repeat string).

@@ -59,6 +59,12 @@
:group 'cider-test
:package-version '(cider . "0.9.0"))

(defcustom cider-test-defining-names '("deftest" "defspec")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer cider-test-defining-forms/macros. Names is a bit vague I think.

@bbatsov
Copy link
Member

bbatsov commented Jan 4, 2017

I'm obviously fine with simple solutions. :-)

This should definitely be added to the manual as well - with more extensive explanations, otherwise few people are going to figure out the possibility of customization even exists.

@bbatsov bbatsov closed this Jan 4, 2017
@bbatsov bbatsov reopened this Jan 4, 2017
@bbatsov
Copy link
Member

bbatsov commented Jan 4, 2017

Sorry about closing the PR - wrong button. :-)

…efining-forms`.

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.)
@ncalexan
Copy link
Contributor Author

ncalexan commented Jan 4, 2017

@bbatsov thanks for such a fast and helpful review. I force pushed a new patch since this rewrote the entire original.

Also, +1 to CIDER's great contributing checklist -- one of the best I've used on github. So far, a great contribution experience \o/

@bbatsov bbatsov merged commit a4d85b6 into clojure-emacs:master Jan 4, 2017
@bbatsov
Copy link
Member

bbatsov commented Jan 4, 2017

Also, +1 to CIDER's great contributing checklist -- one of the best I've used on github. So far, a great contribution experience \o/

Happy to hear this! :-) Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants