-
Notifications
You must be signed in to change notification settings - Fork 168
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
seed: introduce seed user option #165
base: master
Are you sure you want to change the base?
Conversation
Seeing CI failures I expect they are due to older OTP releases using different RNGs. |
I am a bit skeptical about introducing a test that relies on the RNG producing the same random number based on a given seed. Looks to me that this test is a perfect candidate to break not only in some past releases but also in some future ones. I would suggest another test instead; perhaps a weaker one that just checks that PropEr accepts this option. |
In your PR the seed get's only parsed from the options but it does not actually get set as seed for the RNG. The reason for failing the test case is that >=19 PropEr uses You have to set the seed using Furthermore, I think that the test is not good as it depends on the implementation of the RNG. What you want to test instead is that if you set the seed by hand it is set to exactly that value (probably using the (see also Kostis comments) |
Well I’d rather test what comes out of the RNG that way I can be sure I have all the inputs needed for deterministic/reproducible runs. I’m not sure where start_rand should be called if at all since I can reproduce my test’s output with and with the call. Thanks! |
Thinking about it a little bit, what you want to achieve with setting the seed is that runs of the same property with the same seed produce the same input as you say. So I think that running a property twice with the same seed and then comparing that the generated input is the same (e.g. fails on the same value) should be a good test. I still don't think that the test should rely on a specific implementation of a RNG. In |
Disregard commit that just went through... WIP!
What do you think about me also adding the following user options:
There are still a few calls to Something like Thanks a lot for your help! |
I am working on a fix for cleaning up the targeted part from the state. |
test/proper_tests.erl
Outdated
QC = fun (Prop) -> | ||
R = proper:quickcheck(Prop, Opts), | ||
proper:clean_garbage(), | ||
catch proper_target:cleanup_strategy(), |
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.
@TheGeorge this fixed the issue of cleaning up TPBT.
This might work but I really think that proper should clean up after itself
without the user needing to call `proper_target:cleanup_strategy` manually.
`proper:quickcheck` should not leave this stuff in the process dictionary.
…On Sun, May 20, 2018, 15:08 Pierre Fenoll ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In test/proper_tests.erl
<#165 (comment)>:
> @@ -1040,6 +1042,23 @@ options_test_() ->
?FORALL(_,?SIZED(Size,integer(Size,Size)),false),
[{start_size,12}])].
+seeded_test_() ->
+ Seed = os:timestamp(),
+ Opts = [{seed,Seed}, noshrink, {start_size,65536}],
+ QC = fun (Prop) ->
+ R = proper:quickcheck(Prop, Opts),
+ proper:clean_garbage(),
+ catch proper_target:cleanup_strategy(),
@TheGeorge <https://github.com/TheGeorge> this fixed the issue of
cleaning up TPBT.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#165 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAR1j5vmXmHR9WFxbXdp4MfkBm-hFl88ks5t0WrggaJpZM4UCZ2s>
.
|
test/proper_tests.erl
Outdated
state_is_clean() -> | ||
get() =:= []. | ||
-define(state_is_clean(), ?assertEqual([],get())). | ||
-define(_state_is_clean(), ?_assertEqual([],get())). |
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.
what is the advantage of using state_is_clean() to using ?assert(state_is_clean())? For me the old notation is easier to read (an assertion that checks that the state is clean)
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.
I initially prefixed it with assert_
but then thought it was getting too long. Would you be happy if I prefixed it?
The advantage is to show what’s in the get() when it’s not empty and to report the line where the macro is called.
Codecov Report
@@ Coverage Diff @@
## master #165 +/- ##
==========================================
+ Coverage 83.23% 83.53% +0.29%
==========================================
Files 13 13
Lines 3132 3140 +8
==========================================
+ Hits 2607 2623 +16
+ Misses 525 517 -8
Continue to review full report at Codecov.
|
@TheGeorge Any progress on |
I'm sorry for being so slow. I have a patch that fixes the issue and will upload it in a minute. |
#174 should now clean up the strategy correctly. |
Amazing! Will amend once #174 is merged :) Thanks a lot |
Ready! |
No, it's not. For starters, I do not "buy" the reasoning to introduce all these unnecessary Also, please use the current style for the test -- i.e., no commas in the beginning of lines, etc. Finally, and most importantly, I do not really understand what the test is actually doing. It cannot be setting the seed to some thing that is changing (
|
Yes it is: for review. WRT the asserts commit (it is a separate commit, no need to show a full diff...):
That helped a lot debugging failing tests. WRT style: what's in the "etc"? you mention no leading commas, I'm guessing WRT the test:
Thanks for reviewing, I'll push an update soon. |
Hi there, I've replied and pushed a commit 20 days ago now. Anything more I need to do? |
Is this PR still under consideration? This feature might be useful in PropCheck (issue) to check if a persisted counterexample is still valid, or if the generator used to produce that example no longer exist. |
@kostis @TheGeorge is there something that still needs to be finished with this? How can I help to get this merged? |
Rebased ;) |
Rebased again & enhanced the tests:
I'm currently investigating whether reproducibility can be achieved by making |
398bd17
to
f4f9f03
Compare
Signed-off-by: Pierre Fenoll <[email protected]>
Signed-off-by: Pierre Fenoll <[email protected]>
Rebased again. Is CI disabled? |
Any reason this wasn't added earlier? This is an otherwise pretty common option for a QuickCheck implementation.
Note: not sure how much type-checking I need to do on the option's value as not much checking is done on the other options. Plus this might prove useful for RNGs that aren't seeded with the usual triple.