-
-
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?
Conversation
[System.Management.Automation.Language.ReturnStatementAst] | ||
[System.Management.Automation.Language.ExitStatementAst] | ||
[System.Management.Automation.Language.ThrowStatementAst] |
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.
Why are we doing this? To make diagnostic log easier to read?
E.g. throw 123
will get two different breakpoint locations:
- One for
throw 123
AST - One for
123
AST
but command text will bethrow 123
and look like duplicates. Same forexit 123
andreturn 123
.
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.
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.
$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] | ||
} |
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.
Saving future headaches
PR Summary
Extends code coverage to include
break
,continue
,exit
andthrow
statements.return
is not included due to inconsistent behavior (thoughreturn 123
is already covered as a command expression)Adds sort after
Group-Object
to save future headaches with inconsistent report/output order in Windows PowerShell vs PowerShell 6.1 which sorts by default.Fix #1465
PR Checklist
Create Pull Request
to mark it as a draft. PR can be markedReady for review
when it's ready.