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

enable seeding of GLOBAL_RNG when running tests #16924

Merged
merged 1 commit into from
Oct 8, 2017
Merged

Conversation

rfourquet
Copy link
Member

@rfourquet rfourquet commented Jun 14, 2016

When a test fails, the seed failseed of the global RNG is printed. It's then possible to reproduce the failure via julia runtests.jl failedtest --seed=failseed.

Before running this command, if one then wants to re-run the particular test in another context (e.g. at the REPL while debugging), one can insert in failedtest.jl right before the failing test the following line to dump the RNG state: write(open("/tmp/RNG_RESTORE.jl", "w"), "copy!(Base.GLOBAL_RNG, $(Base.GLOBAL_RNG))"). Then to restore the state (e.g. at the REPL): include("/tmp/RNG_RESTORE.jl").
This almost implements #8339 (comment), except that the state is not printed automatically.
This is not very clean, so I hesitate to document it (and if so, where?).
Note: this depends on the unmerged #16919 for copy!.

I am not familiar at all with the file runtests.jl, so careful review is needed.

@tkelman tkelman added the test This change adds or pertains to unit tests label Jun 14, 2016
test/runtests.jl Outdated
# single process testing, bail if mem limit reached, or, on an exception.
isa(resp, Exception) ? rethrow(resp) : error("Halting tests. Memory limit reached : $resp > $max_worker_rss")
# single process testing, bail if mem limit reached.
isa(resp, Exception) || error("Halting tests. Memory limit reached : $resp > $max_worker_rss")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To limit the number of places in the code where the printing of the seed has to be handled. As far as I could understand, the logic is not really modified here.

@rfourquet
Copy link
Member Author

With reference to that comment:

we can run systematically the whole testsuite by providing a fixed seed (or a set thereof) on the command line, known to pass

Would it make sense here to allow multiple "--seed=SEED" command line args, which would run the tests once for each provided seed? (and for example "--seed" without an explicit seed would run with a random seed, like when there is no "--seed" option passed).

@rfourquet rfourquet added the domain:randomness Random number generation and the Random stdlib label Oct 2, 2017
@rfourquet
Copy link
Member Author

Rebased: I will merge in a few days if no objection.

@rfourquet rfourquet merged commit d0430a4 into master Oct 8, 2017
@rfourquet rfourquet deleted the rf/seed-tests branch October 8, 2017 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib test This change adds or pertains to unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants