Skip to content
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

With seed as cli parameter #60

Merged
merged 3 commits into from
Nov 19, 2020

Conversation

raphael-proust
Copy link
Contributor

This PR adds a CLI parameter (-s/--seed) to make the quickcheck mode fully deterministic.

Note that the current state is mostly deterministic: two consecutive runs derive the same original seed from the global Random PRNG. However, linked libraries can change the PRNG state:

  • A linked library may be calling Random.self_init which makes the tests non-deterministic.
  • Updating a dependency may introduce or remove calls to Random.int, changing the determinism.

This PR is not yet tested. I wanted to get a quick mood check before putting significant effort in: Is this change or one like it likely to be merged? Is there interest for such a feature? Any comments on the user interface?

@stedolan
Copy link
Owner

Sounds good to me!

@raphael-proust
Copy link
Contributor Author

👍 I'll test this, make necessary corrections and update this PR.

This parameter makes the non-AFL (quickcheck) tests deterministic.
This parameter sets the number of repetition for non-AFL (quickcheck)
tests.
@raphael-proust
Copy link
Contributor Author

Good news: the seed flag works.


I also added a --repeat flag to set the number of repetitions in quickcheck mode. It also works.

It's not quite redundant with the infinity mode, but it's also not orthogonal. So I'm happy to either remove it, merge both options into a single option (maybe -r 0 can mean infinite?), or make some other changes.


By the way, I found out that it works by finding that the test_calendar actually fails:

$ ./_build/default/examples/calendar/test_calendar.exe -s 0
calendar: ....
calendar: PASS
$ ./_build/default/examples/calendar/test_calendar.exe -s 0 -r 50000
calendar: ....
calendar: FAIL

When given the input:

    [1899-08-31 14:14:45; 1900-07-10 00:40:53]

the test failed:

    1900-07-11 00:40:53 != 1900-07-10 00:40:53

@raphael-proust raphael-proust force-pushed the with-seed-as-cli-parameter branch from 146df13 to f5694c6 Compare August 24, 2020 12:17
@raphael-proust
Copy link
Contributor Author

bump

@raphael-proust
Copy link
Contributor Author

ping

@stedolan stedolan merged commit 0061f60 into stedolan:master Nov 19, 2020
@stedolan
Copy link
Owner

Merged! Thanks, and apologies for forgetting about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants