-
Notifications
You must be signed in to change notification settings - Fork 43
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
StateM.DSL refactor #147
StateM.DSL refactor #147
Conversation
567d012
to
09ca5f3
Compare
@x4lldux, if I see this right, then you changed the existing DSL implementation. Since we wanna break the API, this is not friendly to our users. I would suggest that if we break the API, then we should introduce this via a new module (that's why I mentioned DSL2 earlier in our discussions, see #142 (comment)) and simply mark the old DSL with a hard- or soft-deprecation mark (to be discussed and decided). This gives use the choice of using the newer, nicer DSL with better reporting or stay with the old DSL. If we don't give them that choice, they are required to change their tests or stay with the old version of PropCheck or even leave it behind and move to something different. Let's play nicely with our users! I will take a closer look on your implementation later! |
lib/statem_dsl.ex
Outdated
we want the `find` command to appear three times more often than other commands: | ||
|
||
def weight(_state), do: %{find: 3, cache: 1, flush: 1} | ||
Sequence of commands to be run is generated repeatedly by `c:command_gen/1` |
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.
language: The sequence
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.
"sequence" is both countable and uncountable so I'm not sure it's wrong, but OK, I'll change it.
@x4lldux Good work, thanks! I marked some language improvements in the documentation and please re-introduce the type documentation. And a general comment on discussing the command generation: From my perspective the mastership of defining good models is in generating and properly handling senseless examples. This is contrary to your point of not generating the |
Yes, that's a breaking change, that's why I've mentioned we would need to go to v2.0 (assuming semantic versioning). And one breaking change was already introduced in We can, though, go with b) but rename current implementation to to say |
I'm not advocating it shouldn't be done, I said "there might not be much sense". Straying from the happy path is a good practice! And I also do it. But deleting a user when no users are present, or closing a file while it's not open yet are low hanging fruits - easy to spot by a developer. And generating a commands with easily spotable nonsensical sequences, where all commands are equal, will reduce the chances of finding hidden bugs. So focusing on sequences that on the first look (and sometimes second and third) should work is often more valuable. In that regard both implementation ( |
09ca5f3
to
1429cba
Compare
Fair enough. It was not a critique of the DSL, it was merely remark on the justification, meant jokingly, but this obviously was not the well perceived. sorry! |
Naming things is one of the hardest problems in computer science :-)
IMHO, that's not a good path, since all users of the next version will then have to change their DSL-based tests since it is completely incompatible due to What do you think? A different name? |
No, I didn't took it as a critique or anything. I just tried to explained what I meant behind it. Mainly for "prosperity" in case some users will read it. And because at the beginning I was spending a lot of time testing those low hanging fruits, mostly testing validation and error handling instead of focusing on the core... and then bugs happened. So no apology needed, no offense taken. It was merely a warning on to often taking that route, based on own experience. |
Yes, it's one of the two most hardest things. Alongside cache invalidation and off-by one errors 😜
That's not really any different. When we're eventually on v2.0 and DSL is dropped and we went with ModernDSL, BetterDSL or NewDSL, then one might ask why is it "new" - where's the old? Or, why is it better? Better than what? Also, in that situation it might be prudent to rename (Modern|Better|New)DSL to just DSL, which will also require changes in user's tests. Also, with b)+DSLOld, there's not much that we will be requiring from users. We'll basically make them to do "replace in project", a feature most code editors have built in, or running a |
There's one thing that came to me, though it's hacky a little bit. Though, we will have to put an emphasis on creating a clear documentation for those two modes. |
I understand your thoughts. Currently I am not on the trip towards a 2.0 version which would imply arbitrary and incompatible changes in the API. From that perspective, I would prefer to be conservative regarding the name. When we eventually release a 2.0 version, we can do exactly what you said: We bury the old DSL, rename But until then, I would like to provide both versions to our users, so that they can still use the old DSL if they don't want to change their system but reap the benefits of a newer and enhanced versions of PropCheck. My proposal for the name is |
OK. Let's do this. How about |
Thanks for your effort! |
I'm not sure I would go as far and call it "enhanced", maybe just "more of the same" 😜 As it's just a thin wrapper around Yeah I also like: |
I think the name must be easily distinguishable from In any case, I think I would actually prefer if PropCheck simply moved to v2.0 and reused the name. |
|
Thanks everybody for your thoughts. Then I would prefer |
@alfert would you mind opening an issue about those Pulse ideas? I was under impression that Pulse was supposed to be open-sourced under BSD but never actually did. |
Yes, I will. The current changes are only the initial ones for enabling a scheduler. I never found an open source version of Pulse, but there are the scientific papers and the tutorials. So, we should be able to implement something similar. |
@x4lldux, would you mind todo the renaming? I assumed after that we can merge this PR or is something else to be done? |
@alfert yeah, sure. I'm currently out of town. I'll do it in two days. |
I think https://concuerror.com/ is such an implementation, or at least implements part of what's needed for that. I tried that some years ago, but did not get far with it. Note that the people behind PropEr implemented concuerror. |
@alfert should the DSL be deprecated or soft-deprecated (if that's even possible on a module level)? |
@x4lldux I think soft-deprecation is enough for now. But I can do this for you, i.e. advertising the new DSL implementation. |
Thanks for the reference, I almost forgot about it. I also used concuerror several years ago, I think, it was when the first versions came along and I also did not come that far. concurerror is a fundamental different beast, since it explores and executes all schedulings whereas the QuickCheck approach samples a few. It is effectively a variant of a model checker, and these tools have always the challenge of memory consumption and processing time they need for exploring all possible runs. But I should give it a try to understand if it is usable now and if the effort for re-implementing Pulse is worthwhile (except for the fun of it). What I already found after reading the faq is that they also consider ETS operations, time outs and calls to non-deterministic functions such as |
32c275e
to
44b5d06
Compare
|
44b5d06
to
d5b809d
Compare
StateM.DSL should be just an easier to use DSL for StateM, but it has a different underlying behavior than StateM. That's because StateM.DSL is using it's own implementation of StateM (PropEr's `proper_statem` module). Implementation which has several behavioral differences, some bugs and not every feature was supported. It also incurres additonal maintenance cost of supporting two different versions of similar functionality. See issue alfert#142. This commit deprecates StateM.DSL and introduces new StateM.ModelDSL module as a replacement. It's just a thin wrapper around StateM. Unfortunately this also introduces changed interface. Callback `weight/1` and `args` function inside `defcommand` were replaced by `command_gen/1`, where command generation (along side it's arguments) is contained in one place. Parameters' and return values' types are now the same as with StateM.
Also translates examples to use it instead of inspecting history and state returned by `run_commands`.
d5b809d
to
6d4584b
Compare
Perfect, thanks @x4lldux ! 💚 |
Pull request resolving #142