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

Fix nondeterministic code generation #333

Merged
merged 2 commits into from
Sep 10, 2021
Merged

Fix nondeterministic code generation #333

merged 2 commits into from
Sep 10, 2021

Conversation

asomers
Copy link
Owner

@asomers asomers commented Sep 10, 2021

mockall_derive was internally using HashMap and HashSet and iterating
over their contents. But by default those types use random internal
state, resulting in nondeterministic output. Switch them to use
consistent state.

Reported by: David Tolnay @dtolnay

Also, add a CI check for nondeterminism. When enabled, mock! and
#[automock] will evaluate every call twice and verify that the output is identical.
Also add a test case that is known to currently generate
non-reproducible output. During CI, build the entire test suite with
this mode enabled.

Add a --cfg reprocheck setting.  When enabled, mock! and #[automock]
will evaluate every call twice and verify that the output is identical.
Also add a test case that is known to currently generate
non-reproducible output.
mockall_derive was internally using HashMap and HashSet and iterating
over their contents.  But by default those types use random internal
state, resulting in nondeterministic output.  Switch them to use
consistent state.

Reported by:	David Tolnay @dtolnay
@asomers asomers changed the title Add a CI check for reproducible builds Fix nondeterministic code generation Sep 10, 2021
@asomers asomers merged commit f145b2f into master Sep 10, 2021
@asomers asomers deleted the reproducibility branch September 10, 2021 04:12
asomers added a commit that referenced this pull request Sep 10, 2021
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Jan 31, 2022
Summary: The mentioned PR asomers/mockall#330 was superceded by asomers/mockall#333 and is part of 0.11 release

Reviewed By: dtolnay

Differential Revision: D33881560

fbshipit-source-id: 1676f725739939695e4b7b2b8eb14b08ad27e6c1
facebook-github-bot pushed a commit to facebook/fb303 that referenced this pull request Jan 31, 2022
Summary: The mentioned PR asomers/mockall#330 was superceded by asomers/mockall#333 and is part of 0.11 release

Reviewed By: dtolnay

Differential Revision: D33881560

fbshipit-source-id: 1676f725739939695e4b7b2b8eb14b08ad27e6c1
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Jan 31, 2022
Summary: The mentioned PR asomers/mockall#330 was superceded by asomers/mockall#333 and is part of 0.11 release

Reviewed By: dtolnay

Differential Revision: D33881560

fbshipit-source-id: 1676f725739939695e4b7b2b8eb14b08ad27e6c1
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.

1 participant