qcheck icon indicating copy to clipboard operation
qcheck copied to clipboard

Disable QCheck2 shrinker with a parameter

Open vch9 opened this issue 3 years ago • 3 comments

That'd be cool to disable the shrinker with a boolean in Test.make for instance. I don't know if we can already do this or if it's impossible but this might be a really good feature.

It can happen that the test is wrong and since the generated value is really not-trivial, it takes a lot of time to shrink.

vch9 avatar Mar 18 '22 08:03 vch9

On the one hand I'm supportive of this feature. I've used set_shrink Shrink.nil some_gen in similar situations for "QCheck1" in the past. One could go for a similar design for QCheck2 where the operation changes/removes the Tree children.

On the other hand, to me this indicates short-comings of the QCheck2 shrinkers. I observed these and commented on them in #157 #163 and https://github.com/c-cube/qcheck/pull/153#issuecomment-900238995 while I was trying to test QCheck2 a bit. We need example cases to reproduce and understand what is going on when shrinking takes too long in order to improve the situation. I understand that carving out those from a bigger project can require quite some effort though.

jmid avatar Mar 18 '22 09:03 jmid

I think I can extract one example pretty easily. One co-worker wrote a Merkle Tree or something, it shouldn't have too much dependency with our project.

vch9 avatar Mar 18 '22 10:03 vch9

I think I can extract one example pretty easily. One co-worker wrote a Merkle Tree or something, it shouldn't have too much dependency with our project.

Well, you shouldn't trust my words.

Anyway, I feel that we need it even if the generator is not that long. It's very situational but sometimes, no shrinker is the best solution. My dirty solution currently is:

  make_primitive
    ~gen:(fun rand -> generate1 ~rand gen)
    ~shrink:(fun _ -> Seq.empty)

I'll try to tackle this.

vch9 avatar Jul 11 '22 12:07 vch9