cli icon indicating copy to clipboard operation
cli copied to clipboard

unit tests never seed the RNG

Open mjg123 opened this issue 7 years ago • 2 comments

meaning calls like h.NewFuncName() always return the same values. This can lead to data leaking between tests.

mjg123 avatar Aug 20 '18 12:08 mjg123

This shouldn't be a problem unless:

  • tear down is not run completely
  • you are using the same Fn instance for multiple concurrent runs of the tests

it should be safe to use a non-deterministic RNG (e.g. crypto/rand)

zootalures avatar Aug 20 '18 13:08 zootalures

It comes up during the init-image tests as there is an init-image generated during the tests which gets called randName()-init, so it's the same on every test run. It's possible that one test run could fail to build that image and end up using an image from a previous run, but I'm not considering this a high priority really.

mjg123 avatar Aug 21 '18 18:08 mjg123