-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix #330 - Preserve load-list order #331
Conversation
When using `--load-list` to run tests the tests were always run in a different order than the one provided in the file, even when the `--random` argument was not present: $ stestr run --serial --load-list failing This patch preserves the order of the tests from the file when `--load-list` is used, and it will only randomize it when `--random` is provided: $ stestr run --serial --random --load-list failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks great to me, thanks for tackling this.
def _filter_tests(to_filter, id_map): | ||
# Compatible objects | ||
if extras.safe_hasattr(to_filter, 'filter_by_ids'): | ||
res = to_filter.filter_by_ids(test_ids) | ||
_filter_tests(res, id_map) | ||
# TestCase objects. | ||
elif extras.safe_hasattr(to_filter, 'id'): | ||
test_id = to_filter.id() | ||
if test_id in test_ids: | ||
id_map[test_id] = to_filter | ||
# Standard TestSuites or derived classes. | ||
elif isinstance(to_filter, unittest.TestSuite): | ||
for item in to_filter: | ||
_filter_tests(item, id_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little uneasy about the recursion here. I feel like it probably would have been a bit cleaner to just do it iteratively. But it's not a big deal this should be fine. If it becomes an issue we can always refactor it later
Several issues have been reported about the run order and other odd behavior in running of tests since the 4.0.0 release including a high degree of random failures in stestr CI. #331 is the only likely candidate as to the root cause. In the interest of fixing these issues for people this commit reverts #331. This reverts commit ff25c99.
Several issues have been reported about the run order and other odd behavior in running of tests since the 4.0.0 release including a high degree of random failures in stestr CI. #331 is the only likely candidate as to the root cause. In the interest of fixing these issues for people this commit reverts #331. This revert was already released as part of 4.0.1. Since the main branch adopted `black` code formatting recently it was easier to do the straight revert on the stable branch first as there was conflicts. This reverts commit ff25c99.
When using
--load-list
to run tests the tests were always run in a different order than the one provided in the file, even when the--random
argument was not present:This patch preserves the order of the tests from the file when
--load-list
is used, and it will only randomize it when--random
is provided: