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

Use more platform-independent random test ordering #39441

Merged
merged 1 commit into from
Apr 10, 2020

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: Infrastructure "Make test failures from other platforms more easily reproducible"

Purpose of change

Currently we have difficulty reproducing test failures across platforms. One reason is that we are running the tests in declaration ordr, which depends on the build system & linker. We could use lexicographic order, but even better would be random order.

To that end, it would be helpful if random order (for the same seed) was the same across platforms. This is an attempt to achieve that.

Furthermore, with this change, when a subset of the tests are run, they run in the same order as they would have when more (or all) tests are run. This makes inter-test dependency bugs easier to track down by finding the smallest set of tests which reproduces them.

Describe the solution

Rather than randomly shuffling the tests, we now sort them be an integer value associated with each test. That value is derived from the random seed and test name in a deterministic manner.

Describe alternatives you've considered

std::uniform_int_distribution might also introduce platform-dependence, so this might need further refinement. Considered fixing that now, but decided to wait and see if it's a real problem.

Testing

Ran various subsets of tests with different seeds and observed the above properties.

Additional context

I've opened a similar PR on Catch2 directly, but I wanted to backport the change here because @wapcaplet has been working on resolving failures related to randomly ordered tests, and this should help.

Serves two purposes:
- Should be consistent across platforms.
- When fewer tests are run, the remainder run in the same order.  This
  makes inter-test dependency bugs easier to track down.
@kevingranade
Copy link
Member

I see upstream has some concerns, but they don't apply to us, we can just merge the solution you agree on when it happens.

@kevingranade kevingranade merged commit 80e93bf into CleverRaven:master Apr 10, 2020
@jbytheway jbytheway deleted the catch_random_order branch April 11, 2020 01:14
jbytheway added a commit to jbytheway/Cataclysm-DDA that referenced this pull request Apr 21, 2020
This includes the upstreamed version of CleverRaven#39441, with some improvements.
And various other improvements too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants