-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
Include more statements in code coverage #2554
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,9 +287,16 @@ function Get-CommandsInFile { | |
# In PowerShell 5.0, dynamic keywords for DSC configurations are represented by the DynamicKeywordStatementAst | ||
# class. They still trigger breakpoints, but are not a child class of CommandBaseAst anymore. | ||
|
||
# ReturnStatementAst is excluded as it's not behaving consistent. | ||
# "return" is not hit in 5.1 but fixed in a later version. Using "return 123" we get hit on 123 but not return. | ||
# See https://github.com/pester/Pester/issues/1465#issuecomment-604323645 | ||
$predicate = { | ||
$args[0] -is [System.Management.Automation.Language.DynamicKeywordStatementAst] -or | ||
$args[0] -is [System.Management.Automation.Language.CommandBaseAst] | ||
$args[0] -is [System.Management.Automation.Language.CommandBaseAst] -or | ||
$args[0] -is [System.Management.Automation.Language.BreakStatementAst] -or | ||
$args[0] -is [System.Management.Automation.Language.ContinueStatementAst] -or | ||
$args[0] -is [System.Management.Automation.Language.ExitStatementAst] -or | ||
$args[0] -is [System.Management.Automation.Language.ThrowStatementAst] | ||
} | ||
} | ||
else { | ||
|
@@ -543,6 +550,7 @@ function Get-CoverageCommandText { | |
|
||
$reportParentExtentTypes = @( | ||
[System.Management.Automation.Language.ReturnStatementAst] | ||
[System.Management.Automation.Language.ExitStatementAst] | ||
[System.Management.Automation.Language.ThrowStatementAst] | ||
Comment on lines
553
to
555
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing this? To make diagnostic log easier to read? E.g.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have an answer, I remember the profiler based CC was a big fight for making it capture just the right amount of stuff in the right places, so it is entirely possible that I output more trace points than needed. |
||
[System.Management.Automation.Language.AssignmentStatementAst] | ||
[System.Management.Automation.Language.IfStatementAst] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only updated PSv5+ predicate as we might remove the redundant predicate for v6.
A potential backport would need to extend both predicates.