How tests could be safeguarded for parallel running #953
PavelVozenilek
started this conversation in
Ideas/Requests
Replies: 1 comment
-
Since the language has It would then be used like:
I guess number of static values will be rather low, so it shouldn't result in performance hit. I cannot think of any desired situation, when someone would like test modified value to stay. (Data about tests should be collected by the test runner.) MT safety of statics is up to the user (and yet another argument, why to run tests only serially). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is short followup to recent discord discussion about support for tests.
If tests are required to run in parallel (not a good idea, but whatever), then the "replace this and that function" feature is prone to nasty race conditions.
It could be made safe, by using read-write lock, no matter how the test runner is implemented. It would look like:
This way by-design-MT-unsafe tests would be serialized and would not interfere with normal tests. I assume RW lock is fair and properly implemented. Performance penalty should be negligible.
This still does't help with tests not designed for parallel run and containing subtle bugs, but that's user's fault, wanting concurrency and not handling it properly.
Btw, there may be another requirement for a test runner, ability to run tests in random order, to detect certain class of bugs. If this is implemented (it is easy), then the randomizer seed for the current run should be available somewhere. If tests fail, one should be able to rerun them again with exactly the same seed (meaning no more randomness at this moment).
One could write the seed into a text file somewhere, before the tests run.
It is also possible to spawn small helper process in background, which stores the seed. If all tests finish OK as they should, the background process would close itself. If something failed, then the background process would stay alive, and the next time the tests are run, test runner would retrieve and use the stored seed from that background process. This way test-order-related bugs will be reproducible, and user would not be bothered about text files, how to reseed the randomizer, etc.
Beta Was this translation helpful? Give feedback.
All reactions