-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve public API #66
Comments
Thank you for filing this. It's a good start.
It would be more helpful if you described this in terms of what the library needs to achieve, as opposed to what the API may look like to satisfy those requirements. I don't see making the internal variables public as a good change - it would be confusing at best. The
Can be done by adding
Can be done by adding a new CONFIGURATION item. The function to generate a report is already public.
Wouldn't it be better and easier to set the report path explicitly? This way, the tool using Undercover has control over the "lifetime" of the report file, and is thus in control whether merging happens or not. It should also be in control of the report format, as e.g. merging text reports is not meaningful/possible. Tools that attempt to provide a stable API on top of Undercover should not depend on Undercover defaults, as they are subject to change. This includes the default value of |
Eldev provides a somewhat different interface to the same functionality. You have an intermediate representation called configuration. It is heavily tailored to how Basically, you extract key-value pairs from configuration and set variables identified by keys to the provided values, with a few tweaks. That's pretty much all that
And
Or can also be achieved by not following framework pattern (there are 5 functions I will call, tell me which you don't need, or how I should tweak their arguments for you), but instead library pattern (here are 5 functions, call them as you like; I also have one convenience function that calls them all, in case you don't need fine control). If you just expose the step functions, I could simply avoid calling the one that modifies
Well, in this case I'd like to pass the default onto user. Eldev is meant to be more interactive than e.g. Cask, it is suitable for running from command line, generate local reports and so on. I would like to achieve such things as "if you don't provide report filename, it will be generated in file XYZ", where XYZ comes from |
What do you mean by this? As far as I know, Cask doesn't provide a way to specify and pass configuration on to Undercover from the Cask file.
I think that's perfectly fine. It is much more valuable to retain the ability to modify the Undercover internals while providing a minimal stable public API, rather than cement ourselves into a particular way of doing things after making all our internal guts public. Some of these global variables may even be entirely removed in a future Undercover version.
The options are the public interface. The variables are implementation details. I think it's important to hold on to that distinction. The two may represent the same data identically, or completely differently. For example, what if future versions of Undercover were to add the ability to add exclusions at the function level?
As far as users of Undercover are concerned, the fact that Undercover uses edebug to achieve its goal should be an implementation detail :)
I understand the more important distinction between the two approaches here is "do what I say" vs "this is what I want to do". Two downsides of your proposal:
Since we're talking about something as simple as disabling automatic report generation, simply making this configurable makes much more sense to me.
Generally, this is not possible, and doesn't really make sense outside of specific situations. The default report file name depends on the report type, which is autodetected depending on the environment that Undercover runs in. Furthermore, the text report type can produce its output by If the goal is to allow the user to configure Undercover directly (not through Eldev) or let Undercover decide what to do based on its defaults, then my suggestion would be to reconsider and minimize Eldev's assumptions about what Undercover does. Alternatively, Eldev could provide its own interface for configuring Undercover, in which case Eldev would be in complete control over everything. Perhaps we should take a step back and look at a list of high-level goals that Eldev is trying to achieve with regards to its Undercover integration? |
|
OK, added
OK, added
Hmm... in absence of a unified logging framework in Emacs Lisp, how about the following:
Added
What message does this refer to?
Hmm... I understand this to be a common issue with programmatic use of macros. I don't see any notable downsides in your existing solution, other than the small hit to readability. |
Yeah, sort of would work, but you are overcomplicating things and make it difficult for everyone. What if another user wanted to do something else other than logging at that point? Could have just made sth. like
Current code:
Basically, a message that says if the previous report is deleted or merged with. Or no message if there is no previous report. |
Like what? I think we need to determine who exactly this "everyone" is and what are their use cases before we can progress on this. We certainly can't design an API around conjecture or just add a myriad hooks at every possible point that someone may want to do "something". |
I have no idea. Abort after the first step without actually instrumenting to check if configuration is correct? Something else? In any case, I think that when writing something reusable, it is best not to assume how it might be used and not restrict potential usecases unless there are really compelling reasons.
Of course. A possible solution here would be splitting the I think we have presented our arguments already. Proceed as you decide, this is your project. Eldev, as the higher level here, will have to adapt. |
Yeah, I really don't see a way of making it work in the way that you describe, especially in the merging case. Generating the report would need to be a public function which returns the report object, and then Eldev would need to call / not call the merging function that accepts the report back. There would also need to be a function which checks if there is an existing report to merge? In all of these, there would need to be one such function per report type (in which case Eldev would need to know about all report types?), or make each of these switch by the report type again and call the report type's implementation function (nothing for the report types that can't do merging). That doesn't even include the report file list, and I still don't fully understand the exact requirements for that one. All in all this definitely doesn't look like an improvement, especially for the typical use case of Undercover, which doesn't really align with Eldev's. |
Wouldn't a better place for that be |
Issuing in |
That's slightly misleading, as it will include files which are never actually loaded. Is there a strong reason to stick to the current behavior? |
Current message says "instrumenting [now]", but yeah, you are right, I didn't think about instrumentation happenning lazily. Still, I'd rather give a single message to the tune of "coverage information will be collected for the following files: ...". I'd prefer to avoid intermixing real output with non-important debug messages, which can happen if such messages come from the file handler. |
In other words, I'd rather leave single message, only rephrase it to be not misleading. |
Doesn't Eldev already have the list of files, considering the plan is to use |
Not if |
Yes, I see. I added a message to |
Currently,
undercover
is very difficult to use from other tools, as it provides very few public functions, largely tailored to "the standard way of running".Based on Eldev integration code, which currently often has to dive into internals, I can suggest/request the following improvements:
Don't require to go through
undercover
macro. Currently it largely looks likeinstead, make all the
step-#
functions public and let users just call them in the correct order, easily preprocessing arguments or postprocessing results, calling whatever inbetween and so on.Instead or in addition to passing configuration through
undercover--set-options
, make the variables it sets, likeundercover--report-file-path
, public.Allow callers to specify file lists, don't insist on processing wildcards in it.
Don't call
undercover-report-on-kill
automatically. Instead, let the caller to generate report when he wants.Expose the default value of
undercover--report-file-path
somehow. Since 0.8 it is practically impossible to dig it out of the library. Maybe just add a function that returns it.Clean up, document and expose a way to merge reports vs. saving new. Currently, the only way to start from scratch seems to be manually deleting report file, which is further complicated by inability to find the name (previous point). Starting from scratch seems to be "the sane" option for local reports, while about merging I'm not even sure when it is useful.
Naturally, there can and should be way to work "as now", probably implemented as simple helpers over more common API outlined above.
The text was updated successfully, but these errors were encountered: