#35872 changed uuid4()
to not use the global RNG anymore which means seed!
will no longer affect it.
I have a function that generates a UUID and writes it to a file. The tests should check that the file contains that UUID, therefore it needs to be reproducible somehow. Real example: julia-actions/GitHubActions.jl#26
Is there a good way to accomplish this without creating a custom RNG in the library code that can then be seeded in the test code? The latter would work but it seems like a bad practice
(deleted)
well I should read PRs before commenting
in any case, having a dedicated RNG for your usecase is perfectly fine
another option would be to see if there's a need to check for the exact UUID at all, or if it's sufficient that _a_ UUID is there
Thanks, I'll use a dedicated RNG then
Checking if it contains some UUID in the right places would work for all but one edge case, otherwise I like that idea
I think I found an even better way in the upstream code that I'm reimplementing in Julia: Instead of seeding the RNG, mock uuid4()
to return a specific UUID4. That addresses the edge case and doesn't require changes to the library code itself
Last updated: Dec 28 2024 at 04:38 UTC