fix: Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of :global_scope#350
Open
griggi-ws wants to merge 2 commits intoOpenVoxProject:mainfrom
Open
Conversation
Deferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of global_contextDeferred resolution of Puppet-language functions (e.g. mocks in tests) failing due to lack of :global_scope
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hey folks, found an issue with Deferred resolution of Puppet-language functions while testing a control-repo with Onceover that makes heavy use of some custom functions that are mocked in Onceover's config, and did some digging.
The error was:
Puppet-language functions use the
NamedClosure, which explicitly looks up:global_scopeand returns an empty Hash as a fallback.The
DeferredResolvercreates a new compiler instance which includes:global_scopein itscontext_overrides, but the resolver's call toresolve_futuresdoes not use them.This means when a Puppet-lang Deferred function is resolved,
enclosing_scopeis{}, and when theClosure'sinvokeis called (expecting aScopeobject with the methodwith_global_scope), it errors out since we have an emptyHashinstead of aScope.By wrapping the
resolve_futurescall in acompiler.with_context_overridesblock,:global_scopeis a valid instance ofScope, and the function can be resolved.I added a spec test for Deferred processing of Puppet-lang functions, validated the failure, and applied the fix.