-
Notifications
You must be signed in to change notification settings - Fork 407
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 shrinking of Command sequences and allow customization #632
base: main
Are you sure you want to change the base?
Improve shrinking of Command sequences and allow customization #632
Conversation
There are three improvements here. Together they accomplish more than the sum of their parts. - Instead of shrinking the State with `shrinkWithOrig` and combining the result with the shrunk sequential and parallel commands, just shrink each `Actions` field independently. That is, include in the `shrink` output some Actions where only the State has been shrunk; previously State-shrinking would only occur together with shrinking of at least one command sequence. - Instead of throwing out `Actions` objects that do not satisfy the `actionsPrecond` predicate, throw out individual Command objects to make the `Actions` object conform to `actionsPrecond`. This allows the state and commands to be shrunk jointly in a sensible fashion. - Allow the user to customize command shrinking, at three levels: * `shrinkCommand` shrinks individual commands. * `shrinkSequentialCommands` shrinks the sequential part. * `shrinkParallelCommands` shrink the parallel command sequences. If the user only defines `shrinkCommand`, the other two will be defined using `implicitly` for `List`.
As an example where the changes I'm suggesting here really help, see https://gist.github.com/jonaskoelker/ac60ded3a310b8f0fb548a1eda9f8859 and https://gist.github.com/jonaskoelker/b4a1d00a3da97c6d56e7b3d8fee02716 (though you will need to add Try removing all the implementations of the bounded queue methods, replacing them with |
I see Travis complaining that the methods I added only exist after the patch and not before, in the context of One thing that can easily be done is to split this PR into two, where one does everything except add the customization option, and the other adds the customization option. If the only complaints about binary compatibility are about the public methods I've added, I have a hunch that moving those into a separate PR should let everything else go through. That of course just narrows the problem without fixing anything. But maybe it'll enable a binary-compatible minor-version release with some of these changes? (Assuming you want them in the first place, of course.) |
Yeah, there is a tool that is flagging that there is a binary compatability since
You can fix by adding the following to private def newMethods = Seq(
"org.scalacheck.commands.Commands.shrinkCommand",
"org.scalacheck.commands.Commands.shrinkSequentialCommands",
"org.scalacheck.commands.Commands.shrinkParallelCommands",
) |
Is there anyone watching this repo who feels able to assess/review this...? |
That would probably be the best thing to do. There are fewer experts on the commands API still around, so reducing the complexity in this part of the library would more likely get your PRs merged. I know tests of shrinking is difficult and there aren't many existing commands tests, but if you can add tests, that would probably help, as well. Sorry for the delay. I didn't know you had fixed MiMa. |
There are three improvements here. Together they accomplish more than
the sum of their parts.
Instead of shrinking the State with
shrinkWithOrig
and combiningthe result with the shrunk sequential and parallel commands, just
shrink each
Actions
field independently. That is, include in theshrink
output some Actions where only the State has been shrunk;previously State-shrinking would only occur together with shrinking
of at least one command sequence.
Instead of throwing out
Actions
objects that do not satisfy theactionsPrecond
predicate, throw out individual Command objects tomake the
Actions
object conform toactionsPrecond
. This allowsthe state and commands to be shrunk jointly in a sensible fashion.
Allow the user to customize command shrinking, at three levels:
shrinkCommand
shrinks individual commands.shrinkSequentialCommands
shrinks the sequential part.shrinkParallelCommands
shrink the parallel command sequences.If the user only defines
shrinkCommand
, the other two will bedefined using
implicitly
forList
.