You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix non-deterministic output when using mockfiles - #365
When --mockfiles is used, the generated output can differ between runs even though the inputs are the same.
In the following case, TargetMock gets the members of either FooMock or BarMock, depending on the run.
On another run, foo is added instead of bar. Neither should be there in the first place.
Sendable is not in the sources, so it is looked up in parentMocksByInheritedType (added in #338). Every mock conforming to Sendable matches there, and the table keeps whichever comes last while iterating parentMocks, which is a dictionary.
I changed two things:
Sendable and Error are no longer looked up as a parent protocol.
A type inherited by more than one mock is not registered in parentMocksByInheritedType. The same problem happens with other types such as CustomStringConvertible, so this is not limited to Sendable.
One behavior change: if mockfiles have two or more mocks for the same protocol and none of them is named <Protocol>Mock, none of them is used as the parent mock. Before this change one of them was picked depending on the run.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. 1 out of 2 committers have signed the CLA.
✅ sidepelican ❌ tokizuoh You have signed the CLA already but the status is still pending? Let us recheck it.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. 1 out of 2 committers have signed the CLA.
✅ sidepelican ❌ tokizuoh You have signed the CLA already but the status is still pending? Let us recheck it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
--mockfilesis used, the generated output can differ between runs even though the inputs are the same.In the following case,
TargetMockgets the members of eitherFooMockorBarMock, depending on the run.On another run,
foois added instead ofbar. Neither should be there in the first place.Sendableis not in the sources, so it is looked up inparentMocksByInheritedType(added in #338). Every mock conforming toSendablematches there, and the table keeps whichever comes last while iteratingparentMocks, which is a dictionary.I changed two things:
SendableandErrorare no longer looked up as a parent protocol.parentMocksByInheritedType. The same problem happens with other types such asCustomStringConvertible, so this is not limited toSendable.One behavior change: if mockfiles have two or more mocks for the same protocol and none of them is named
<Protocol>Mock, none of them is used as the parent mock. Before this change one of them was picked depending on the run.