gmock-actions_test depends on order of test execution
@derekmauro is already working on this.
Since Jun 23, 2020.
- Dominant language
- C++
- Stars
- 39.6k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
In gmock-actions_test, tests
MockMethodTest.CanReturnMoveOnlyValue_InvokeandDefaultValueTest.GetWorksForMoveOnlyIfSet
both change DefaultValue<std::unique_ptr<int>>::producer_ without restoring the state after the test.
This causes the following failures:
-
DefaultValueTest.GetWorksForMoveOnlyIfSetfails when it is executed afterMockMethodTest.CanReturnMoveOnlyValue_Invoke.
With 50% chance, the following call fails:
gmock-actions_test --gtest_filter="MockMethodTest.CanReturnMoveOnlyValue_Invoke:DefaultValueTest.GetWorksForMoveOnlyIfSet" --gtest_shuffle -
DefaultValueTest.GetWorksForMoveOnlyIfSetfails when it is executed repeatedly:
gmock-actions_test --gtest_filter="DefaultValueTest.GetWorksForMoveOnlyIfSet" --gtest_repeat=2
In practice, we observed the problem when executing googletest’s own unit tests on AIX (without shuffle, without repeat), because the test execution order was different than on other platforms.
Since the order of test execution is undefined, the tests should work in any order.
Locally, we fixed the problem by adding the line
DefaultValue<std::unique_ptr<int>>::Clear();
at the end of both tests.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.