Throw on unbound user-provided scriptblocks #2551
Merged
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.
PR Summary
Throws when user provides scriptblocks that are not bound to a session state. They would be executed in Pester's module state which could cause unexpected behaviour.
Examples:
Fix #2411
Checklist:
Add-AssertionOperator -Test
(type:ScriptBlock
)Add-ShouldOperator -Test
(type:ScriptBlock
)AfterAll -Scriptblock
(type:ScriptBlock
)AfterEach -Scriptblock
(type:ScriptBlock
)BeforeAll -Scriptblock
(type:ScriptBlock
)BeforeDiscovery -ScriptBlock
(type:ScriptBlock
)BeforeEach -Scriptblock
(type:ScriptBlock
)Context -Fixture
(type:ScriptBlock
)Describe -Fixture
(type:ScriptBlock
)InModuleScope -ScriptBlock
(type:ScriptBlock
)It -Test
(type:ScriptBlock
)Mock -MockWith
(type:ScriptBlock
)Mock -ParameterFilter
(type:ScriptBlock
)New-PesterContainer -ScriptBlock
(type:ScriptBlock[]
)Should-All -FilterScript
(type:ScriptBlock
)Should-Any -FilterScript
(type:ScriptBlock
)Should-Throw -ScriptBlock
(type:ScriptBlock
)Run.Scriptblock
Run.Container
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.