-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
test/random.jl: segregate deterministic tests at the end #8339
Conversation
How would you get the RANDOM_SEED.txt file from a failed travis run? We also need a way to rerun the tests with the failing seed. One solution to the first issue might be to create a |
Printing the RNG state right before the failed test would be even better. That way you can reproduce the failure without running any other tests. |
That would require a method to get and set the internal RNG state. Do we even want that to be part of the API? Tests also often depends on variables declared at an earlier point of the test file, so you would have to run the other tests as well. |
Well, I would want it. Not sure how many RNGs allow it. Setting up local variables is possible without running everything before, especially now that we print better info in failed tests. |
The state is stored as a I agree, that it would be useful to have the state printed for failing tests. |
I of course didn't think of Travis... |
|
||
using Base.Random.RANDOM_SEED | ||
|
||
srand() |
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.
Maybe something like?
srand() #Reseed the RNG with entropy from the OS
seed = rand(Uint)
#seed =
println("Running random tests with seed\nseed = 0x",hex(seed))
srand(seed)
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'm not sure why you would like seeding with rand(Uint)
... is it so to be able to print only an Uint
instead of RANDOM_SEED
which is an array of four Uint32
?
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.
It was for convenience and shorter printing. If you think there are any benefit in using RANDOM_SEED directly, please do that.
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 would then prefer to print RANDOM_SEED
as an Uint128
. So do you suggest I update this PR to print to the screen instead of to the file?
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.
Yes, for Travis and bug reports, it seems better to print to STDOUT. Uint128 seems like a good idea.
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.
Done.
2291a7e
to
f13fb96
Compare
6c7c7e3
to
1a4c02f
Compare
What's the final word here? |
I think that there the problem is still there (most tests don't "require" the |
See #8313 for context and in particular #8313 (comment) for the rationale of this change.
In short, the first test in "test/random.jl", which needed to seed the global RNG with a deterministic value (
srand(0)
), was leaking determinism on all the tests coming after it.