Fixes #1028 - Code Coverage for proxy functions/steppablePipelines (updated to v5.0.3) #1656
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.
1. General summary of the pull request
Note: This PR contains the same bug fix as #1494, but is based on the
v5.0
branch instead ofmaster
.Pester generates all breakpoints using a combination of line number and column number. PowerShell does not trigger breakpoints on the proxy function constructs described in #1028 when initiated using both line and column number, but it does when using line number only. This appears to be a bug within PowerShell itself, as the behavior can be replicated outside of Pester like so:
...which results in this output:
Rather than trying to rewrite Pester to create breakpoints without column specifications, this PR includes proxy functions using steppable pipelines in the
IsIgnoredCommand
private function. I feel this is appropriate because in proxy command situations, the steppable pipeline constituents are already covered by breakpoints.It does this be validating two criteria:
'^{?& \$wrappedCmd @PSBoundParameters ?}?$'
, which matches the specific constructs created when auto-generating a proxy command using[System.Management.Automation.ProxyCommand]::Create()
.'*$steppablePipeline.Begin($PSCmdlet)*$steppablePipeline.Process($_)*$steppablePipeline.End()*'
, which matches when all three of the steppable pipeline steps have been defined in the function or file where this proxy command is defined.Since there is no out-of-the-box mechanism to recursively iterate through nested AST objects to get to the topmost parent, this PR also includes a new private function,
Get-AstTopParent
, that does exactly that.Fix #1028