-
Notifications
You must be signed in to change notification settings - Fork 179
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
Use multimethod for cider.nrepl.middleware.test/report
#510
Conversation
Partially address clojure-emacs/cider#2215. Users should be able to define new message types. With this change, such new messages will only be handled properly if `report` produces a map adhering to the schema of that of an existing type (e.g. `:fail`). This could be another point of extension in the future.
Codecov Report
@@ Coverage Diff @@
## master #510 +/- ##
==========================================
- Coverage 72.02% 71.96% -0.06%
==========================================
Files 33 33
Lines 2152 2169 +17
Branches 112 112
==========================================
+ Hits 1550 1561 +11
- Misses 490 496 +6
Partials 112 112
Continue to review full report at Codecov.
|
I'm a little uncertain about this PR, because I'm uncertain who would be expected to implement this? matcher-combinators:: I could see some reluctance from a library author for hooking into more reports. How long before you're supporting N reporters that you've never even heard of? Especially when hooking in will require ugly code which has conditional requires to hook the multi-method. There's an alternative avenue to explore here: cider-nrepl doing the integration directly. This is hindered in this case by matcher-combinators not using a namespaced keyword for the matching. If it did that, we could comfortably implement a matcher for it, as the API doesn't depend on any particular code being loaded. |
That's a valid point indeed. I often wish we hadn't had to deal with @claynon Any thoughts on this? |
CIDER doing integration directly is what we've done w/ integrating It's certainly not a sustainable model, though. It'd make CIDER directly or indirectly on a bunch of projects we have no control over. In the case of HTO the functionality'd been stable and demonstrably useful for years, and is a relatively small change. Making |
@SevereOverfl0w do you mean making @bbatsov I've been thinking a bit about clojure test frameworks (most of my experience is with midje) and I'm curious to hear your (and others') opinions on the trade-offs of |
I don't fully understand the implications of this kind of changes on cider, so I might have a naive expectation. |
@phillipM I think making that change would make your event more "isolated" in your library. That isolation means cider can integrate with that value, without being concerned about whether or not another library will add a I think you would also need to commit to not changing your event in a breaking way. If you did, you would need to call it
There's a difficult balance here. Should matcher-combinators depend on cider-nrepl in order to do the integration? Or should cider-nrepl just look for data that matcher-combinators happens to produce and integrate with that? I'm quite against libraries having specific tooling integrations, as author bias seems to fester there (oh, it just works with cider, use that instead of IntelliJ!). Using pure data is very beneficial here, as it means there's no dependency cost. But it requires an accretion commitment. (Can we get t-shirts or a certificate or something that has that on?) |
Another aspect which occurs to me after posting that comment, is that cider-nrepl's multi-method may be removed in the future, in favour of report generation moving to orchard. I don't think cider-nrepl is ready to commit to a stable API here, given all the recent refactoring. |
@phillipM Well, we've focused on clojure.test mostly because of its dominant position in the Clojure ecosystem and the fact that we didn't have resources to deal with supporting natively other testing libraries. As a long-time Ruby dev I think RSpec is leaps and bounds better that clojure.test and it provided a lot of inspiration for Midje and Expectations. A general disappointment of mine is that test libraries are rarely written with extensibility or integration with dev tools in mind.
Yeah, this is likely going to happen soon, but it guess it's not a big deal. Unfortunately coming up with the great and stable APIs everyone desires requires time and energy which no one is willing to commit. :-) |
atom to reflect test results and summary statistics." | ||
:type) | ||
|
||
(defmethod report :default [m]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me it'd be a good idea to add some short docstrings to the methods, so people would get an idea what exactly are we handling with them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defmethod
doesn't accept a docstring, which is just as well--there's already a docstring for the defmulti
, and the methods are just variants that dispatch on :type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I've forgotten this. Haven't used multimethods in quite a while. My point was mostly that some of the dispatch values might not mean much to casual readers of the code.
@xiongtx I'm guessing we should add some integration notes in CIDER's manual, otherwise people are going to have a hard time figuring out what they are supposed to do. |
Due to lack of further feedback I'll go forward and merge this. @claynon Let us know how this worked out for you. |
Partially address clojure-emacs/cider#2215.
Users should be able to define new message types.
With this change, such new messages will only be handled properly if
report
produces a map adhering to the schema of that of an existing type (e.g.:fail
). This could be another point of extension in the future.